Showing posts with label define hash table. Show all posts
Showing posts with label define hash table. Show all posts

Thursday, February 9, 2017

Hash table in C#



In C# hash table is the collection of key or values, which is used to map a key to value. We can use any non-null object as a key; we can retrieve the items from hash table by providing key.
The common function used in hash table is given below:

Add – used to add a pair of value to Hashtable
Syntax
HashTable.Add (Key, Value)
Hashtable h;
h.Add(“1”, “Sachin”);
  
ContainsKey – used to checked a specified key exist or not.
Syntax
bool HashTable.ContainsKey (key)
h.contains(“1”);

ContainsValue - used to checked a specified value exist or not.
Syntax 
bool HashTable.Containsvalue (value)
h.containsvalue(“Sachin”);

Remove – used to delete specified key or values.
Syntax 
HashTable.Remove(key)
h.remove(“1”)