HashSet is a collection containing only unique elements.
In order to use it, the following line needs to be added:
Insertion is done via the Add function. Like in the following example:
Output:
Notice that Tokyo is contained only once, since no duplicates are allowed.
Size is the count of HashSet elements. It's accessed via the Count property.
Output:
Certain values can be removed via the remove function.
Output:
A value can be checked if contained via the contains method.
Output:
It can be iterated via for and for-each loop:
Output: