首页 > 代码库 > Dictionary的遍历总结

Dictionary的遍历总结

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的遍历总结