hi
what is Hash set..where it is used in real time...
explain with example
thank u
in advance
Hash set in c#
2 Answers
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
Kirtan PatelRank #292 · 8.6K reputationPosted Dec 24, 2009, 7:14 PM EST
Although a HashSet is a list of elements, it does not inherit the IList interface. Instead it just inherits the ICollection interface. What this means is elements inside a HashSet cannot be accessed through indices, only through an enumerator (which is an iterator).
Additionally, since a C#.NET HashSet is modeled after a mathematical set, certain functions were implemented such as Union, Intersection, IsSubsetOf, IsSupersetOf. These can come in handy when working with multiple sets.
A resulting difference between a HashSet and a List is that the HashSet's Add method is a boolean function, which returns true of an element was added and false if it wasn't (because it was not unique).
srinivas reddy40 reputationPosted Dec 24, 2009, 7:44 PM EST