static void DisplayHashtable(MyHashtable t) { Console.WriteLine("==>> Display Values in Hashtable <<=="); foreach (DictionaryEntry de in t) { Console.WriteLine($"key: {de.Key,-10}Value: {de.Value}"); } Console.WriteLine(); }
static object SearchHashtable(MyHashtable t, int k) { // use the Get method and pass to it the key object value = t.Get(k); if (value == null) { return("key not found"); } return(value); }
static void RemoveItemFromHashtable(MyHashtable t, int k) { try { t.Remove(k); } //catch(InvalidOperationException ioe) catch (ArgumentNullException) { Console.WriteLine($"key: {k} not in hashtable!"); } }