Difference between various String.Compare overloads

Specifically, what is the difference between

It seems to me that the second offers additional parameters (comparison using any culture, not just current or invariant, ignore special characters, ignore the width of katakanas (!!), etc.) than the first . Both were implemented in .NET 2.0, so I think this is not a backward compatibility issue.

So, what's the difference and when should I use the first, and when should I use the second?

I looked through this post and this article, but I think they are dealing with slightly different issues.

+6
source share
1 answer

Your answer is given in the notes for the second overload.

http://msdn.microsoft.com/en-us/library/cc190529.aspx

“A comparison uses a culture parameter to obtain culture-specific information, such as casing rules and the alphabetical order of individual characters. For example, a particular culture may indicate that certain combinations of characters are treated as one character, upper and lower case characters are compared in a certain way, or that the sort order of a character depends on the characters that precede or follow it. "

Another overload uses the default culture.

+3
source

Source: https://habr.com/ru/post/916092/


All Articles