How to loop through dictionary in C#

Created: 12/06/2013 12:43:03 p.m.

How to loop/iterate through dictionary in C#

Just a sample code to loop your dictionary.

In this totorial you will see how to use iterate a ditionary in .NET, using C#
it is one of the posible ways

        private static void LoopMyDictionary()
            Dictionary<int, string> items = new Dictionary<int, string>();
            items.Add(1, "Item 1");
            items.Add(2, "Item 2");
            foreach (KeyValuePair<int, string> item in items)
                Console.WriteLine("First property:" + item.Key + ", Second Property: " + item.Value);


First property: 1, Second Property: Item 1

First property: 2, Second Property: Item 2



User: test Comment date: 18/04/2020 01:37:39 p.m.

Go to Comments