Category Archives: .NET

How to iterate a C# dictionary

The following snippet shows an easy way to iterate a C# dictionary: Dictionary<int, string> dictionary = new Dictionary<int, string>(); dictionary.Add(1, "Cat"); dictionary.Add(2, "Dog"); dictionary.Add(3, "Horse"); foreach (var item in dictionary) { // do stuff with item Console.WriteLine(string.Format("{0} – {1}", item.Key, … Continue reading

Posted in .NET | Tagged , , | Comments Off