using System; using System.Collections; using System.Collections.Generic; namespace codeTest { class Program { static void Main(string[] args) { //C#集合类型 //数组都继承于System.Array 长度固定 //一维数据 int[] numbers = new int[5]; //二维数据 int[,] numbers2 = new int[5,5]; //数组的数据 int[][] numbers3 = new int[5][]; //初始化 int[] intArray = new int[5] { 1, 2, 3, 4, 5 }; int[] intArray1 = new int[] { 1, 2, 3, 4, 5 }; int[] intArray2 = { 1, 2, 3, 4, 5 }; string[,] strArray = new string[,] { { "A", "B" }, { "C", "D" } }; string[][] strArray1 = new string[][] { new string[] { "A", "B" }, new string[] { "C", "D" } }; //列表都继承于System.Collection ArrayList AL = new ArrayList(); AL.Add(100); AL.Add("ccc"); AL.Remove(100); Console.WriteLine(AL[0]); List<int> ListA = new List<int>(); ListA.Add(100); ListA.AddRange(new int[] { 101, 102, 103 }); ListA.Contains(100); ListA.Remove(100); ListA.Insert(1, 200); ListA.InsertRange(1, new int[] { 201, 202, 203 }); ListA.IndexOf(100); //哈希表 Hashtable ht = new Hashtable(); ht.Add(1, "1"); ht.Add("2", 2); //字典 Dictionary<int, string> dic = new Dictionary<int, string>(); dic.Add(1,"1"); //根据Key值排序 SortedList<int, int> a = new SortedList<int, int>(); //stack queue } } }