// Creates a dictionary in which both keys and values are strings.
Dictionary<string, string> dict = new Dictionary<string, string>();
// Add items to the dictionary. Each has a key and a value.
dict.Add("Don Giovanni","Serial seducer ends up in hell.");
dict.Add("Un Ballo in Maschera","Everyone ends up at a masked ball where someone gets stabbed.");
dict.Add("Aida","Unhappy love triangle.");
dict.Add("Der fliegende Holländer","A ghostly captain who can't hold down a relationship gets a shot at redemption every seven years.");
dict.Add("Gotterdammerung","The last chapter of 15 hours of opera.");
dict.Add("Turandot","Princess gives death-or-marriage riddles, a bold prince takes a chance, and everyone stays up all night trying to figure out who he is.");
// Displays the contents of the dictionary.
Console.WriteLine("\nA list of favorite operas: ");
foreach (KeyValuePair<string, string> pair in dict)
{
// String methods to format the output since both are strings.
A list of favorite operas:
Key: Don Giovanni Value: Serial seducer ends up in hell.
Key: Un Ballo in Maschera Value: Everyone ends up at a masked ball where someone gets stabbed.
Key: Aida Value: Unhappy love triangle.
Key: Der fliegende Holländer Value: A ghostly captain who can't hold down a relationship gets a shot at redemption every seven years.
Key: Gotterdammerung Value: The last chapter of 15 hours of opera.
Key: Turandot Value: Princess gives death-or-marriage riddles, a bold prince takes a chance, and everyone stays up all night trying to figure out who he is.