Given a StringComparison
instance, how should I check if it is case sensitive?
Should I compare it to all currently known case sensitive values in the enum?
StringComparison sc = ...;
bool isCaseSensitive = false
|| sc == StringComparison.CurrentCulture
|| sc == StringComparison.InvariantCulture
|| sc == StringComparison.Ordinal;
Yes, for the enum form (StringComparison
) that's fine. MS is incredibly unlikely to add another StringComparison
value now, given that adding a value to an enum is effectively a breaking change.
For a StringComparer
, it's rather harder :(
See more on this question at Stackoverflow