Collation.Compare Method (string, int, string, int, int)Collation.Compare Method (String, Integer, String, Integer, Integer)Collation::Compare Method (String^, int, String^, int, int)

Compares two specified stringStringString objects.

Syntax

Public MustOverride Function Compare( _
    value1 As String, _
    index1 As Integer, _
    value2 As String, _
    index2 As Integer, _
    length As Integer _
) As Integer
public abstract int Compare(
    string value1,
    int index1,
    string value2,
    int index2,
    int length
)
public:
virtual int Compare(
    String^ value1, 
    int index1, 
    String^ value2, 
    int index2, 
    int length
) abstract
 

Parameters

value1

Type: System.StringSystem.StringSystem::String^

The first string to use in the comparison.

index1

Type: System.Int32System.Int32System::Int32

The position of the substring within value1.

value2

Type: System.StringSystem.StringSystem::String^

The second string to use in the comparison.

index2

Type: System.Int32System.Int32System::Int32

The position of the substring within value2.

length

Type: System.Int32System.Int32System::Int32

The maximum number of characters in the substrings to compare.

Return Value

Type: System.Int32System.Int32System::Int32

-1, 0, or 1, depending on whether the value of the value1 is respectively less than, equal to, or greater than the value of value2.

Exceptions

ExceptionCondition
ArgumentNullExceptionArgumentNullExceptionArgumentNullException value1 or value2 is null a null reference (Nothing in Visual Basic) nullptr.