What is the HashTable in C#?Joe Wilson12yAsked May 5, 2014, 4:21 AM EDTSolvedShareLinkedInXCopy linkSave Please, Give Examples about the subject. Joe Wilson
What is the HashTable in C#?Joe Wilson12yAsked May 5, 2014, 4:21 AM EDTSolvedShareLinkedInXCopy linkSave Please, Give Examples about the subject. Joe Wilson
Abhishek JaiswalRank #126 · 17.5K reputation12y agoPosted May 5, 2014, 6:57 PM EDT✓ Accepted answer0HELLOpls go through these linkshttp://www.c-sharpcorner.com/UploadFile/2072a9/dictionaries-and-hash-table-in-C-Sharp496/http://msdn.microsoft.com/en-us/library/system.collections.hashtable.aspxhttp://www.tutorialspoint.com/csharp/csharp_hashtable.htm:)0
VulpesRank #55 · 29.2K reputation12y agoPosted May 5, 2014, 5:35 AM EDT0A Hashtable is a .NET class which associates a key with a value and enables you to quickly retrieve a value given its key.Internally, it is stored as a collection of DictionaryEntry structures.The keys and values can be of any type but the keys must be unique, immutable and not null. However, none of these restrictions apply to the values.Here's a simple example which illustrates the use of Hashtable:using System;using System.Collections;class Person{ public string Name {get; set;} public int Age {get;set;} public Person(string name, int age) { Name = name; Age = age; } public override string ToString() { return String.Format("Name = {0}, Age = {1}", Name, Age); } }class Program{ static void Main() { Hashtable ht = new Hashtable(); ht.Add(1, new Person("Fred", 30)); ht.Add(2, new Person("George", 40)); // retrieve Person with a key of 2 Person p = (Person)ht[2]; Console.WriteLine("Key = {0}, {1}", 2, p); // remove person with a key of 2 ht.Remove(2); // iterate through remaining members foreach(DictionaryEntry de in ht) { Console.WriteLine("Key = {0}, {1}", de.Key, de.Value); } Console.ReadKey(); }}The output is:Key = 2, Name = George, Age = 40Key = 1, Name = Fred, Age = 300Joe WilsonRank #631 · 3.8K reputation12y agoPosted May 5, 2014, 10:42 AM EDT0Thank you for your answer, but if it is possible, Please Suggest Websites about the subject.0VulpesRank #55 · 29.2K reputation12y agoPosted May 5, 2014, 10:45 AM EDT0Sure, check out this one:http://www.dotnetperls.com/hashtable0Joe WilsonRank #631 · 3.8K reputation12y agoPosted May 5, 2014, 11:18 PM EDT0Thank you for your attention.0Joe WilsonRank #631 · 3.8K reputation12y agoPosted May 5, 2014, 11:19 PM EDT0Thank you very much for these suggestions.Joe Wilson0Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign inKnow the answer?Answer a question in the forums and earn +20 SHARP for every answer.See unanswered questionsForumsTop experts01Arun PottiAnswers in the forums20answers02Tahir AnsariAnswers in the forums5answers03Kamlesh KumarAnswers in the forums5answers04Sam HobbsAnswers in the forums4answers05Željko PerićAnswers in the forums3answers?YouYour name goes here.Every answer: 20 SHARP.JoinFull leaderboard →2026DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Joe WilsonRank #631 · 3.8K reputation12y agoPosted May 5, 2014, 10:42 AM EDT0Thank you for your answer, but if it is possible, Please Suggest Websites about the subject.0
VulpesRank #55 · 29.2K reputation12y agoPosted May 5, 2014, 10:45 AM EDT0Sure, check out this one:http://www.dotnetperls.com/hashtable0
Joe WilsonRank #631 · 3.8K reputation12y agoPosted May 5, 2014, 11:18 PM EDT0Thank you for your attention.0
Joe WilsonRank #631 · 3.8K reputation12y agoPosted May 5, 2014, 11:19 PM EDT0Thank you very much for these suggestions.Joe Wilson0
Abhishek JaiswalRank #126 · 17.5K reputationPosted May 5, 2014, 6:57 PM EDT
pls go through these links
http://www.c-sharpcorner.com/UploadFile/2072a9/dictionaries-and-hash-table-in-C-Sharp496/
http://msdn.microsoft.com/en-us/library/system.collections.hashtable.aspx
http://www.tutorialspoint.com/csharp/csharp_hashtable.htm
:)
VulpesRank #55 · 29.2K reputationPosted May 5, 2014, 5:35 AM EDT
The output is:
Joe WilsonRank #631 · 3.8K reputationPosted May 5, 2014, 10:42 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 5, 2014, 10:45 AM EDT
http://www.dotnetperls.com/hashtable
Joe WilsonRank #631 · 3.8K reputationPosted May 5, 2014, 11:18 PM EDT
Joe WilsonRank #631 · 3.8K reputationPosted May 5, 2014, 11:19 PM EDT
Joe Wilson
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts