想建立List定义二维动态数组,一维是int类型,二维是一个结构体。请问这个是如何定义。赋值和使用,有没有简单的例子代码?
(1),(string1,double1,int1)
(2),(string2,double2,int2)
(3),(string3,double3,int3)
......
有知道的帮我下吧。先谢谢啦!
List<Tuple<int, MyStruct>>
能给个简单的代码学习下吗?如何定义、赋值、和使用数组里面的一维和二维变量?
public struct S { public string String1; public double Double1; public int Int1; } List<KeyValuePair<int, S>> l = new List<KeyValuePair<int, S>>(); l.Add(new KeyValuePair<int, S>(1, new S { Double1 = 0, Int1 = 0, String1 = "123" })); l.Add(new KeyValuePair<int, S>(2, new S { Double1 = 0, Int1 = 0, String1 = "123" })); l.Add(new KeyValuePair<int, S>(3, new S { Double1 = 0, Int1 = 0, String1 = "123" })); foreach (var item in l) { Console.WriteLine("{0} {1} {2} {3}", item.Key, item.Value.String1, item.Value.Double1, item.Value.Int1); }