C#中的Directory
C# 中的map集合遍历取值方法如下:
Dictionarymap = new Dictionary (); map.Add("1", "Chinese"); map.Add("2", "Math"); map.Add("3", "English"); Console.WriteLine("Dictionary遍历方式:"); Console.WriteLine("方法1:"); foreach (var v in map ) { Console.WriteLine("Key:" + v.Key + ";Value:" + v.Value); } Console.WriteLine("方法2:"); foreach (KeyValuePair kvp in map ) { Console.WriteLine("Key:" + kvp.Key + ";Value:" + kvp.Value); } Console.WriteLine("方法3:"); foreach (string key in map.Keys) { Console.WriteLine("Key:" + key + ";Value:" + myDictionary[key]); } Console.WriteLine("方法4:"); foreach (string value in map.Values) { Console.WriteLine("Value:"+value); }



