Monday, April 15, 2013

Dictionary in c#.net

Dictionary: The Dictionary type provides fast lookups with keys to get values. With it we use keys and values of any type, including ints and strings.


Dictionary<string, string> KeyValue = new Dictionary<string, string>();
KeyValue.Add("A", "Load");
KeyValue.Add("B", "Save");

foreach (KeyValuePair<string, string> item in KeyValue) {
   Console.WriteLine("{0} = {1}", item.Key, item.Value);
}

No comments:

Post a Comment