A HashSet is an unordered collection of the unique elements. It comes under the System.Collections.Generic namespace. It is used in a situation where we want to prevent duplicates from being inserted in the collection. As far as performance is concerned, it is better in comparison to the list. HashSet
Here, mySet is the name of the HashSet.
Below given are some examples to understand the implementation in a better way:
6 0 3
- C# | Remove all elements in a collection from a HashSet
- C# | Remove elements from a HashSet with conditions defined by the predicate
- C# | Remove the specified element from a HashSet
- C# | Number of elements in HashSet
- C# | Check if HashSet and the specified collection contain the same elements
- C# | Check if a HashSet and a specified collection share common elements
- C# | Remove all elements from the Hashtable
- C# | Remove all elements from OrderedDictionary
- C# | Remove all elements from the ArrayList
- C# | Remove all elements from the SortedSet
- C# | Remove all elements from the Collection<T>
- C# | Remove all elements from a SortedList
- C# | Remove a range of elements from the ArrayList
- C# | Remove elements from a SortedSet that match the predicate
- C# | Remove all elements of a List that match the conditions defined by the predicate
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.