C# 常用数组集合

1.定义数组 并赋值

 int[] Qpum = { 1, 2, 3 };

 多维数  string[,] name={{"j","k"},{"a","s"}};

 数组的取值通过索引取值Qpnum[1]

 

2. 集合  常用方法 Add()   Remove()

 ArrayList A = new ArrayList();
  //值类型是object
  A.Add("123");
  A.Add(1);
  A.Add(2);
  A.Remove(1);
集合

 

3. 泛型集合 实例化时指定要添加的类集合

定义集合  
List<string> Lt = new List<string>();
 Lt.Add("name");
 Lt.Add("kk");
 Lt.Insert(0, "age");
 Lt.Remove("kk");
 Lt[0]  //获取集合的值
泛型集合

4.哈希表

  哈希表  值没有规定的类型  
  增加值时 采用键值对方式
  Hashtable ht = new Hashtable();
  ht.Add("1", "20");
  ht.Add("2", "21");
哈希表

5. 字典类型

指定了键值对类型  
 Dictionary<string, string> d = new Dictionary<string, string>();
 d.Add("jerry","Newy");
字典类型

 

posted on 2017-03-22 10:45  逆方向  阅读(446)  评论(0编辑  收藏  举报

导航