Click or drag to resize
StringCompare Method (String, String, CultureInfo, CompareOptions)
Compares two specified String objects using the specified comparison options and culture-specific information to influence the comparison, and returns an integer that indicates the relationship of the two strings to each other 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,
	CultureInfo culture,
	CompareOptions options
)

Parameters

strA
Type: SystemString
The first string to compare.
strB
Type: SystemString
The second string to compare.
culture
Type: System.GlobalizationCultureInfo
The culture that supplies culture-specific comparison information.
options
Type: System.GlobalizationCompareOptions
Options to use when performing the comparison (such as ignoring case or symbols).

Return Value

Type: Int32
A 32-bit signed integer that indicates the lexical relationship between strA and strB, as shown in the following tableValueConditionLess than zerostrA is less than strB.ZerostrA equals strB.Greater than zerostrA is greater than strB.
Exceptions
ExceptionCondition
ArgumentExceptionoptions is not a CompareOptions value.
ArgumentNullExceptionculture is null.
See Also