Dictionary<string, int> myDictionary = new Dictionary<string, int> { { "apple", 1 }, { "banana", 2 }, { "cherry", 3 } }; foreach (KeyValuePair<string, int> item in myDictionary) { Console.WriteLine("Key: {0}, Value: {1}", item.Key, item.Value); }
Dictionary<string, int> myDictionary = new Dictionary<string, int> { { "apple", 1 }, { "banana", 2 }, { "cherry", 3 } }; foreach (KeyValuePair<string, int> item in myDictionary) { Console.WriteLine("Key: {0}, Value: {1}", item.Key, item.Value); }