IDictionary: Iterating over map/value pairs : IDictionary « Data Structure « C# / CSharp Tutorial






using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;

public class MainClass
{
    public static void Main()
    {
        IDictionary<string, decimal> salaryMap = new Dictionary<string, decimal>();

        salaryMap.Add("S", 60.5M);
        salaryMap.Add("W", 10.0M);
        salaryMap.Add("J", 30.99M);

        foreach (KeyValuePair<string, decimal> kvp in salaryMap)
            Console.WriteLine("{0} == {1}", kvp.Key, kvp.Value);
    }
}
S == 60.5
W == 10.0
J == 30.99








11.30.IDictionary
11.30.1.IDictionary: Add some entries into the dictionary
11.30.2.IDictionary: remove one entry
11.30.3.IDictionary: Check whether certain keys exist in the map
11.30.4.IDictionary: Retrieve some values from the map
11.30.5.IDictionary: iterate over the map and add up the values
11.30.6.IDictionary: Iterating over map/value pairs
11.30.7.Creating a list from a dictionary