CompareInfo.Compare Method (String, Int32, String, Int32, CompareOptions)
Compares the end section of a string with the end section of another string using the specified CompareOptions value.
Assembly: mscorlib (in mscorlib.dll)
abstract Compare : string1:string * offset1:int * string2:string * offset2:int * options:CompareOptions -> int override Compare : string1:string * offset1:int * string2:string * offset2:int * options:CompareOptions -> int
The first string to compare.
The zero-based index of the character in string1 at which to start comparing.
The second string to compare.
The zero-based index of the character in string2 at which to start comparing.
A value that defines how string1 and string2 should be compared. options is either the enumeration value Ordinal, or a bitwise combination of one or more of the following values: IgnoreCase, IgnoreSymbols, IgnoreNonSpace, IgnoreWidth, IgnoreKanaType, and StringSort.
Return ValueType: System.Int32
A 32-bit signed integer indicating the lexical relationship between the two comparands.
The two strings are equal.
less than zero
The specified section of string1 is less than the specified section of string2.
greater than zero
The specified section of string1 is greater than the specified section of string2.
offset1 or offset2 is less than zero.
offset1 is greater than or equal to the number of characters in string1.
offset2 is greater than or equal to the number of characters in string2.
options contains an invalid CompareOptions value.
If a security decision depends on a string comparison or a case change, you should use the InvariantCulture property to ensure that the behavior is consistent regardless of the culture settings of the operating system.
When possible, you should call string comparison methods that have a parameter of type CompareOptions to specify the kind of comparison expected. As a general rule, use linguistic options (using the current culture) for comparing strings displayed in the user interface and specify Ordinal or OrdinalIgnoreCase for security comparisons.
Notes to Callers:
Character sets include ignorable characters, which are characters that are not considered when performing a linguistic or culture-sensitive comparison. The CompareOptions.Ordinal or CompareOptions.OrdinalIgnoreCase for the options parameter.method does not consider such characters when performing a culture-sensitive comparison. To recognize ignorable characters in your comparison, supply a value of
Available since 8
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 8.1