![]() |
A HashSet is an unordered collection of the unique elements. It is found in 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 Syntax: mySet.Contains(T item); Here, mySet is the name of the HashSet and item is the required element to locate in the HashSet Return Type: This method returns true if the HashSet Below given are some examples to understand the implementation in a better way: Example 1:
Output:
Required Element is present Example 2:
Output:
Required Element is not present Reference: |
Reffered: https://www.geeksforgeeks.org
C# |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 9 |