IDictionary: iterate over the map and add up the values : 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);
        decimal total = 0.0M;
        foreach (decimal d in salaryMap.Values)
            total += d;
        Console.WriteLine("{0:C}", total);
        
    }
}
$101.49








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