hello-algo/codes/csharp/utils/Vertex.cs
hpstory 56b20eff36
feat(csharp) .NET 8.0 code migration (#966)
* .net 8.0 migration

* update docs

* revert change

* revert change and update appendix docs

* remove static

* Update binary_search_insertion.cs

* Update binary_search_insertion.cs

* Update binary_search_edge.cs

* Update binary_search_insertion.cs

* Update binary_search_edge.cs

---------

Co-authored-by: Yudong Jin <krahets@163.com>
2023-11-26 23:18:44 +08:00

30 lines
775 B
C#

/**
* File: Vertex.cs
* Created Time: 2023-02-06
* Author: zjkung1123 (zjkung1123@gmail.com), krahets (krahets@163.com)
*/
namespace hello_algo.utils;
/* 顶点类 */
public class Vertex(int val) {
public int val = val;
/* 输入值列表 vals ,返回顶点列表 vets */
public static Vertex[] ValsToVets(int[] vals) {
Vertex[] vets = new Vertex[vals.Length];
for (int i = 0; i < vals.Length; i++) {
vets[i] = new Vertex(vals[i]);
}
return vets;
}
/* 输入顶点列表 vets ,返回值列表 vals */
public static List<int> VetsToVals(List<Vertex> vets) {
List<int> vals = [];
foreach (Vertex vet in vets) {
vals.Add(vet.val);
}
return vals;
}
}