Code Inspection: Can simplify 'Contains' before 'Add'
Add method in
HashSet<T> in C# is designed not to add duplicates to the set. If the element is already in the set, the method will just return
false and will not throw any exceptions. Therefore, calling
Add is redundant in this case.
This also applies to custom implementations of the
ISet<T> interface, where the Add method must behave in the same way.