HashSet constructor has an overload that lets
you pass in a custom
IEqualityComparer. There are a
few of these defined for you already in the static
StringComparer class, a few of which ignore case. For
var set = new HashSet(StringComparer.OrdinalIgnoreCase);
You'll have to make this change at the time of constructing the
HashSet. Once one exists, you can't change the
IEqualityComparer it's using.
Just so you know, by default (if you don't pass in any
IEqualityComparer to the
constructor), it uses
The question appears to have changed after I posted my answer.
If you have to do a case insensitive search in an existing
HashSet, you will have to do a
set.Any(s => string.Equals(s, item, StringComparison.OrdinalIgnoreCase));
Там няма ніякага спосабу абыйсці гэта.