Skip to main content

Hashset

A hash set is a set of unique values where duplicates are not allowed. C# includes the HashSet<T> class in the generic collections namespace. All HashSet<T> elements are required to be of the same type T.

Hash sets are different from other collections because they are simply a set of values. They do not have index positions and elements cannot be ordered.

The HashSet<T> class provides high-performance set operations. HashSets allow fast lookup, addition, and removal of items, and can be used to implement either dynamic sets of items or lookup tables that allow finding an item by its key.