Search notes:

System.Collection.IDictionary (interface)

System.Collection.IDictionary defines an interface that is able to store key/value pairs. These key/value pairs are stored in System.Collections.DictionaryEntry objects.
System.Collection.IDictionary implements System.Collections.ICollection and System.Collections.IEnumerable.

Iterating over an IDictionary interface

In C#, it's possible to iterate over key/value pairs with foreach … in.
This is demonstrated in the following example: The method GetEnvironmentVariables() method of System.Environment returns the set of environment variables as an IDictionary. The foreach loop iterates over this set and prints the name of the environment variable (Key) and its value (Value).
using System;
using System.Collections;

static class Prg {

   public static void Main() {

      IDictionary envVars = Environment.GetEnvironmentVariables();

      foreach (DictionaryEntry envVar in envVars) {
         Console.WriteLine("{0,-40}: {1}", envVar.Key, envVar.Value);
      }
   }
}
Github repository .NET-API, path: /System/Collections/IDictionary/iterate-over.cs

Index