一、List列表
參考:https://www.cnblogs.com/dyhao/p/9501479.html????
????定義:List <string> listReceiveId = new List<string>();
????大邢灯啊:List.Count;
????清空:List.Clear();
????添加元素:List.Add(元素);
????移除指定位置元素:list1.RemoveAt(下標(biāo));
????list元素根據(jù)指定字符拼接成一個(gè)字符串:string str = string.Join("_",list.ToArray());
二、Dictionary字典
結(jié)構(gòu):Dictionary<[Key]>,[Value]>,有很多元素的時(shí)候可以用它揖闸。
????包含在System.Collections.Generic控件中揍堕,在使用前必須聲明它的鍵類型和值類型。
????參考:https://www.cnblogs.com/ChenMM/p/9479987.html
????定義:Dictionary<int,string> myDictionary = new Dictionary<int,string>();
????大行ㄈ馈:myDictionary.Count;
????清空:myDictionary.Clear();
????添加元素:myDictionary.Add(1,"a");
????刪除元素(根據(jù)鍵值):myDictionary.Remove(1);
????加入元素不存在則添加元素:if(!myDictionary.ContainsKey(2)){myDictionary.Add(2,"b");}
????通過KeyValuePair遍歷元素:
????foreach(KeyValuePair<int,string>kvp in myDictionary){string a= kvp.Key;string b = kvp.Value;}
????得到哈希表鍵的集合:Dictionary<int,string>.KeyCollection keyCol = myDictionary.Keys;
????得到哈希表值的集合:Dictionary<int,string>.ValueCollection valCol = myDictionary.Values;
????使用TryGetValue方法獲取指定鍵對(duì)應(yīng)的值:
????string slove = ""; if(myDictionary.TryGetValue(5,out slove)){string a = slove;}
三鹤啡、數(shù)組
創(chuàng)建:
string[] myArray=new string[10];
string[] myArray={"1","2"};
string[] myArray=new string[3]{"1","2","3"};
string[] myArray=new string[]{"1","2","3","4"};
清空:
Array.Clear(myArray, 0, myArray.Length);