Dictionarydict = new Dictionary (); // Adding elements to the dictionary dict.Add("apple", 5); dict.Add("banana", 7); dict.Add("orange", 3); // Removing an element with key "banana" dict.Remove("banana");
DictionaryPackage Library: The Dictionary class is part of the System.Collections namespace in the .NET Framework library.dict = new Dictionary (); // Adding elements to the dictionary dict.Add("name", "John"); dict.Add("age", "25"); dict.Add("city", "New York"); // Removing an element with key "age" if it exists if (dict.ContainsKey("age")) { dict.Remove("age"); }