不規則 Array, List and Dictionary
不規則Array
obj[0] = new object[] { "a", "b" };
obj[1] = new object[] { "c", "d" };
List
list.Add(new object[]{"a","b"});
object[][] obj = new object[2][];
obj[0] = new object[] { "a", "b" };
obj[1] = new object[] { "c", "d" };
list.AddRange(obj);//將陣列放入List中
//List or Dictionary 計算長度不是Length, 而是Count
//List可以轉成Array: list.ToArray();
//List有sort方法
Dictionary
dic.Add("A", 1);
dic.Add("B", 2);
//dic["A"]為1, dic["B"]為2
//用foreach取得Dictionary的值
foreach (KeyValuePair<string, int> val in dic)
{
string str = val.Key;
int num = val.Value;
}