How does C-sharp string.compare compare?

string.compare (strA,strB)
on the Internet, it is said that the ASCII codes of two strings are compared
strA > strB return 1
strA=strB return 0
strA < strB return-1
look up the table:
Alav 97
b > a returns 1 correct
a > A. Why does a return-1 when comparing A with A. Does
use an ASCII code?

Jan.08,2022

not by ascii, but by sort order. Sort lowercase a before uppercase.

the first parameter is-1, and the first parameter is 1

.

MSDN makes it clear that String.Compare is to calculate the relative distance between two strings
https://docs.microsoft.com/en.

. The

algorithm should be the famous Levenshtein distance
https://en.wikipedia.org/wiki.

. The code above

wikipedia can be run directly, and the result is consistent with String.Compare (take absolute value).

Menu