String.Compare behavior

How can it be? (This is taken from the VS2008 direct window)

?string.Compare("-", "+")
-1
?string.Compare("-0", "+0")
1
+3
source share
2 answers

From the comments on String.Compare (highlighted by me):

The comparison uses the current culture to obtain culture information, such as casing rules and the alphabetical order of individual characters. For example, a culture may indicate that certain combinations of characters are treated as a single character, or 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 .

+8

#:

, . , , , , , .

. , , . System.Globalization.CompareOptions.

+1

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


All Articles