Explain Set Collection in C#? | C# Interview Question | .Net Interview Question

The HashSet implements set logic in its many instance methods. We use methods such as Union on different HashSets to solve problems. This makes some programs simpler.

1. HashSet : Hashset is an optimized set collection. It helps eliminates duplicate strings or elements in an array. It provides a simple syntax for taking the union of elements in a set. This is performed in its constructor.
2. SortedSet : Sortedset is an ordered set collection. We have many elements and want to store them in a sorted order and also eliminate all duplicates from the data structure. The SortedSet is part of the System.Collections.Generic namespace.