Jake Stewart Jake Stewart - 1 year ago 62
C# Question

What is the best way to iterate over a Dictionary in C#?

I've seen a few different ways to iterate over a Dictionary in C#. Is there a standard way?

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