Compare has multiple overload functions to list the simplest one.
Public static int compare (string stra, string strb)
Return Value
* Less Than Zero, and less than strb;
* Zero, stra is equal to strb;
* Greater than zero and greater than strb.
This comparison uses the current culture settings to obtain information specific to the culture, such as case sensitivity rules and the alphabetic order of each character. For example, you can specify a combination of certain characters as a single character, or use a special method to compare upper and lower case characters, or the character arrangement order depends on the characters before or after it.
If one of the parameters is a null reference, the string is greater than the null reference. If both parameters are null references, the comparison results are equal.
The most important parameter here is the comparisontype parameter of the stringcomparison type:
Stringcomparison. currentculture uses the region sensitive sorting rule to compare strings with the current region.
Stringcomparison. currentcultureignorecase compares strings using region-sensitive sorting rules and the current region, while ignoring the case of the strings to be compared.
Stringcomparison. invariantculture compares strings using region-sensitive sorting rules and fixed regions.
Stringcomparison. invariantcultureignorecase compares strings using region-sensitive sorting rules and fixed regions, while ignoring the case sensitivity of the strings to be compared.
Stringcomparison. ordinal compares strings using sequence number sorting rules. This is to compare the Unicode encoding of each character, and the encoding is small. In the past, many languages used this comparison method.
Stringcomparison. ordinalignorecase uses sequence number sorting rules and ignores the case of the strings to be compared. Based on stringcomparison. ordinal, the case is ignored.