Sunday, July 22, 2007

Dictionary: keyword, Code Listing

• Provides a mapping from a set of keys to set of values
• Each addition to the dictionary consists of a value and its associated key
• Dictionary class is implemented as a HashTable
• Key must be unique
• Initial capacity of a dictionary is 3, reallocation happens as new elements are added
• Declaration: Dictionary dictName = new Dictionary();
• ContainsKey: myDict.ContainsKey(“keyHere”);
• Loop Contents:
foreach(KeyValuePair kvp in myDict)
{
Console.WriteLine(kvp.Key, kvp.Value);
}

No comments:

Post a Comment