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]); }
时间: 2024-10-14 10:58:04