The Distinct
method is not in the HashSet<>
, but the IEnumerable<>
, which is implemented by the HashSet<>
.
Extension methods cannot be omitted from certain types. After adding to the type, all this type and any derivative will receive an extension method.
Just to demonstrate, if you extended the object
, you would put everything in by adding the appropriate namespace. Therefore, do not add:
namespace System { public static class ObjectExtensions { public static void Garbage(this object foo) { } } }
source share