Click or drag to resize
StringCompare Method (String, String, StringComparison)
Compares two specified String objects using the specified rules, and returns an integer that indicates their relative position in the sort order.

Namespace: System
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static int Compare(
	string strA,
	string strB,
	StringComparison comparisonType
)

Parameters

strA
Type: SystemString
The first string to compare.
strB
Type: SystemString
The second string to compare.
comparisonType
Type: SystemStringComparison
One of the enumeration values that specifies the rules to use in the comparison.

Return Value

Type: Int32
A 32-bit signed integer that indicates the lexical relationship between the two comparands.Value Condition Less than zero strA is less than strB. Zero strA equals strB. Greater than zero strA is greater than strB.
Exceptions
ExceptionCondition
ArgumentExceptioncomparisonType is not a StringComparison value.
NotSupportedExceptionStringComparison is not supported.
See Also