Earn income with your C# skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest self-service freelancing marketplace for people like you.

How to iterate over a dictionary in C#

Below are 3 ways to iterate over the keys and values in a dictionary:


// iterate over C# Dictionary Keys and Values

foreach (KeyValuePair<string, string> entry in myDictionary)
{
   // do something with entry.Value or entry.Key
}

// itrate over C# Dictionary Values only

foreach (var key in myDictionary.Keys)
{
   // do something with key
}

// iterate over C# Dictionary Keys only

foreach (var value in myDictionary.Values)
{
   // do something with value
}



Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas.      Vsn 1.3.0