public static void Main()
{
// Creates and initializes a new StringDictionary.
StringDictionary myCol = new StringDictionary();
myCol.Add("red", "rojo");
myCol.Add("green", "verde");
myCol.Add("blue", "azul");
Console.WriteLine("Count: {0}", myCol.Count);
// Display the contents of the collection using foreach. This is the preferred method.
Console.WriteLine("Displays the elements using foreach:");
PrintKeysAndValues1(myCol);
// Display the contents of the collection using the enumerator.
Console.WriteLine("Displays the elements using the IEnumerator:");
PrintKeysAndValues2(myCol);
// Display the contents of the collection using the Keys, Values, Count, and Item properties.
Console.WriteLine("Displays the elements using the Keys, Values, Count, and Item properties:");
PrintKeysAndValues3(myCol);
// Copies the StringDictionary to an array with DictionaryEntry elements.
DictionaryEntry[] myArr = new DictionaryEntry[myCol.Count];
myCol.CopyTo(myArr, 0);
// Displays the values in the array.
Console.WriteLine("Displays the elements in the array:");
Console.WriteLine(" KEY VALUE");
for (int i = 0; i < myArr.Length; i++)
Console.WriteLine(" {0,-10} {1}", myArr[i].Key, myArr[i].Value);
Console.WriteLine();
// Searches for a value.
if (myCol.ContainsValue("amarillo"))
Console.WriteLine("The collection contains the value \"amarillo\".");
else
Console.WriteLine("The collection does not contain the value \"amarillo\".");
Console.WriteLine();
// Searches for a key and deletes it.
if (myCol.ContainsKey("green"))
myCol.Remove("green");
Console.WriteLine("The collection contains the following elements after removing \"green\":");
PrintKeysAndValues1(myCol);
// Clears the entire collection.
myCol.Clear();
Console.WriteLine("The collection contains the following elements after it is cleared:");
PrintKeysAndValues1(myCol);
}