Exemple #1
0
 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();
 }
Exemple #2
0
        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);
        }
Exemple #3
0
 static void RemoveItemFromHashtable(MyHashtable t, int k)
 {
     try
     {
         t.Remove(k);
     }
     //catch(InvalidOperationException ioe)
     catch (ArgumentNullException)
     {
         Console.WriteLine($"key: {k} not in hashtable!");
     }
 }