|
using
System;
using
System.Collections;
class
HashTableDemo
{
public
static void Main()
{
//Create an instance of HashTable
Hashtable HT = new
Hashtable();
//Add elements(Key-Value pairs) to the HashTable
HT.Add(1,
"Prasad");
HT.Add(2,
"Giri");
HT.Add(3,
"Ravi");
//Determines whether the Hashtable contains a specific key
Console.WriteLine("Is key 2 Present:"+
HT.ContainsKey(2).ToString());
//Determines whether the Hashtable contains a specific value
Console.WriteLine("Is value Giri Present:"
+ HT.ContainsValue("Giri"));
//Removes the element with the specified key from the Hashtable
HT.Remove(2);
//Removes all elements from the Hashtable.
HT.Clear();
}
}
|