You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How about to split the Equals String extension method in 2 Equals() and EqualsIgnoreCase()
each should a have a default behavior and accepts a new Comparison Enum like the StringComparison Enum that has only 3 values
CurrentCulture
InvariantCulture
Ordinal
as a parameter (like Equals() now)
I think it will make it easier to use for most cases (and more likely to be noticed with an IDE )
I don't understand what you mean by "you can alter it by passing a StringComparison Enum". Does that mean that your proposed EqualsIgnoreCase should accept StringComparison as the second parameter? at that point might as well as just use the existing Equals method.
Why does this has to be an extension method? might as well as add it as an instance method if it's going to be useful for discoverability.
2. I think there's a potential concern with the default culture; every other instance methods (e.g. IndexOf, Compare etc...) use current culture when not specified. This suggestion does not however and use Ordinal, and this would break the tradition of defaulting to culture sensitive comparison. Unless people read the documents (which usually people don't), they would assume that this is culture sensitive, case insensitive comparison. Apparently I was thinking that string.Equals(string) defaults to current culture when its not. 😅
If it's expected to be used without the second parameter for the most case, why bother providing one at all? I think we could just have EqualsIgnoreCase(string) one. It seems rather weird to be able to also specify case insensitivity by StringComparison. (e.g. str1.EqualsIgnorecase(str2, StringComparison.OrdinalIgnoreCase)
p.s: if we're going to add this as an instance method, I think #14065 suits better.
You're right it does not need to be an extension method.
About your issue about the second parameter, my suggestion is that it shouldn't need the second
parameter only if you want to change the default.
About your issue with passing a StringComparison.OrdinalIgnoreCase I edit the issue to create a new enum that accepts only 3 values without the IgnoreCase values
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.
This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.
Activity
Gnbrkm41 commentedon Aug 20, 2019
Duplicate of https://github.com/dotnet/corefx/issues/649?
Gnbrkm41 commentedon Aug 20, 2019
I don't understand what you mean by "you can alter it by passing a StringComparison Enum". Does that mean that your proposed EqualsIgnoreCase should accept StringComparison as the second parameter? at that point might as well as just use the existing Equals method.
BluePositive commentedon Aug 21, 2019
@Gnbrkm41 I edited the title to make it more understandable.
Gnbrkm41 commentedon Aug 22, 2019
So, are you suggesting that your suggestion would be used like:
and it's better than
?
BluePositive commentedon Aug 22, 2019
@Gnbrkm41 in most cases it will be
and that is more straightforward than
Gnbrkm41 commentedon Aug 24, 2019
2. I think there's a potential concern with the default culture; every other instance methods (e.g. IndexOf, Compare etc...) use current culture when not specified. This suggestion does not however and use Ordinal, and this would break the tradition of defaulting to culture sensitive comparison. Unless people read the documents (which usually people don't), they would assume that this is culture sensitive, case insensitive comparison.Apparently I was thinking thatstring.Equals(string)defaults to current culture when its not. 😅EqualsIgnoreCase(string)one. It seems rather weird to be able to also specify case insensitivity by StringComparison. (e.g.str1.EqualsIgnorecase(str2, StringComparison.OrdinalIgnoreCase)p.s: if we're going to add this as an instance method, I think #14065 suits better.
BluePositive commentedon Sep 3, 2019
@Gnbrkm41
parameter only if you want to change the default.
dotnet-policy-service commentedon Dec 25, 2025
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.
This process is part of our issue cleanup automation.
dotnet-policy-service commentedon Jan 8, 2026
This issue will now be closed since it had been marked
no-recent-activitybut received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.