Csharp/C Sharp by API/System.Collections.Generic/IDictionary — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 15:11, 26 мая 2010
IDictionary.Add
<source lang="csharp"> 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); salaryMap.Remove("W"); }
}
</source>
IDictionary.ContainsKey
<source lang="csharp"> 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); salaryMap.Remove("W"); }
}
</source>
IDictionary.Values
<source lang="csharp"> 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); }
}
</source>