1. 程式人生 > >Dictionary的遍歷總結

Dictionary的遍歷總結

cnblogs ons ring col span blog pair clas 通過

Dictionary<string,string> list=new Dictionary<string,string>;
foreach(var item in list) { Console.WriteLine(item.Key+item.Value); } //KeyValuePair<T,K> foreach(KeyValuePair<string,string> kv in list) { Console.WriteLine(kv.Key+kv.Value); } //通過鍵的集合取 foreach(string key in
list.Keys) { Console.WriteLine(key+list[key]); }

Dictionary的遍歷總結