To iterate over an IDictionary<x,y> interface, use the KeyValuePair<x,y> structure.  Following is a simple example:

using System;
using System.Collections.Generic;

namespace CSharp411
{
    class Program
    {
        static void Main( string[] args )
        {
            IDictionary<string, int> rights = new Dictionary<string, int>();
            rights.Add( "Drive", 16 );
            rights.Add( "Vote", 18 );
            rights.Add( "Drink", 21 );

            foreach (KeyValuePair<string,int> right in rights)
            {
                Console.WriteLine( "Right={0}, Age={1}", right.Key, right.Value );
            }
            Console.ReadLine();
        }
    }
}

This example produces the following output:

Right=Drive, Age=16
Right=Vote, Age=18
Right=Drink, Age=21

Share and Enjoy:
  • Digg
  • Twitter
  • Facebook
  • Reddit
  • StumbleUpon
  • LinkedIn
  • Google Bookmarks
  • Slashdot