取代陣列的好東西
張貼日期:2011/2/15 上午 02:24:35
List<string>//<可以指定變數型別>
System.Collections.Generic.List<string> ls= new System.Collections.Generic.List<string>();
用來當作一維陣列的好物
輸入順序就是輸出順序,除非使用了排序指令
key:value成對,並且是string,key有重複
NameValueCollection nvc=new NameValueCollection();
foreach ( var paramItemBytes in
from string key in param.Keys
select string.Format( paramrHeader , key , param[key] )
into paramItem
select Encoding.UTF8.GetBytes( paramItem ) ) {
memStream.Write( paramItemBytes , 0 , paramItemBytes.Length );
}
Dictionary<string ,string> dict= new Dictionary<string , string>();<可以指定變數型別,可以指定變數型別>
KEY不能重複
依照加入順序排序
支援foreach( KeyValuePair<string, string> kvp in dict ){
}
神奇的Hashtable
Hashtable ht = new Hashtable();
ht.add("key","value");
KEY是唯一的,Vlue可為任意值或是物件或是null.
加入之後自動被排序,所以輸出排序並非輸入排序
支援foreach( DictionaryEntry de in ht){
}