Hash table
Use of hashtable in C# , ASP.Net?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Lalit MRank #1,186 · 1.5K reputationPosted Nov 13, 2009, 8:36 PM EST
Creating a Hashtable
The Hashtable class in C# represents a hashtable. The following code creates a Hashtable:
private Hashtable hshTable = new Hashtable();
Adding Items to a Hashtable
Add method of Hashtable is used to add items to the hashtable. The method has index and value parameters. The following code adds three items to hashtable.
hshTable .Add("Author1", "Mahesh Chand"); hshTable .Add("Author2", "James Brand"); hshTable .Add("Author3", "Mike Gold"); Retrieving an Item Value from Hashtable The following code returns the value of "Author1" key: string name = hshTable["Author1"].ToString(); Removing Items from a HashtableThe Remove method removes an item from a Hashtable. The following code removes item with index "Author1" from the hashtable:
hshTable.Remove("Author1");
Looking through all Items of a Hashtable
The following code loops through all items of a hashtable and reads the values.
more information you will get from this link
Understanding HashTable
Basic Laval