1 List<int> clist = new List<int>();
2 clist.Add(0);
3 clist.Add(2);
4 clist.AddRange( new int []{3,4,5,6,7});//往集合中添加数组,最后该数组内的元素,转换成集合中的元素
5 clist.RemoveAll(r=>r>5);//删除集合中大于5的元素
6 clist.Remove(3);//删除集合中元素值为3的元素
7 Console.WriteLine(clist.Count);//集合现在实际含有的数量
8 Console.WriteLine(clist.Capacity);//集合可以容纳的数量
9 clist.RemoveAt(2);//删除集合中索引为2的元素
10 clist.RemoveRange(1, 2);//删除集合中一定范围的元素
11 clist.Insert(1,200);//在集合中索引为1的位置插入int 200
12 clist.InsertRange(1,new int []{1,2,3});//在集合中索引为1的位置插入数组
13
14 //集合-->数组
15 int[] nums = clist.ToArray();//集合转换成数组
16
17 //数组-->集合
18 int[] mun1 = new int() { 1,2,3,4,5};
19 List<int> ilist = mun1.ToList();//数组转转换成集合