C#集合类型

时间:2021-05-28 18:58:01
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[];
//二维数据
int[,] numbers2 = new int[,];
//数组的数据
int[][] numbers3 = new int[][]; //初始化
int[] intArray = new int[] { , , , , };
int[] intArray1 = new int[] { , , , , };
int[] intArray2 = { , , , , };
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();
AL.Add("ccc");
AL.Remove();
Console.WriteLine(AL[]); List<int> ListA = new List<int>();
ListA.Add();
ListA.AddRange(new int[] { , , });
ListA.Contains();
ListA.Remove();
ListA.Insert(, );
ListA.InsertRange(, new int[] { , , });
ListA.IndexOf(); //哈希表
Hashtable ht = new Hashtable();
ht.Add(, "");
ht.Add("", );
//字典
Dictionary<int, string> dic = new Dictionary<int, string>();
dic.Add(,""); //根据Key值排序
SortedList<int, int> a = new SortedList<int, int>(); //stack queue
}
} }