HashSet has been introduced in framework 3.5. It inherits the ICollection interface. HashSet cannot be accessed through indices, only through an enumerator.
HasSet is modeled upon mathematical set. It has methods such as Union, Intersection, IsSubsetOf, IsSupersetOf.
Add method of HashSet is boolean unlike List. HashSet allows only unique values. So, if the value already exists then “Add” method returns false.
So, if the list requires to contain unique values then it is better and faster to use HashSet instead of List.
07 November, 2010
Commenting is closed for this article.