NullableTypes Class Library

NullableString.Compare Method (NullableString, Int32, NullableString, Int32, Int32, Boolean)

Compares substrings of the two specified NullableString structures.

[Visual Basic]
Overloads Public Shared Function Compare( _
   ByVal a As NullableString, _
   ByVal indexA As Integer, _
   ByVal b As NullableString, _
   ByVal indexB As Integer, _
   ByVal length As Integer, _
   ByVal ignoreCase As Boolean _
) As Integer
public static int Compare(
   NullableString a,
   int indexA,
   NullableString b,
   int indexB,
   int length,
   bool ignoreCase


A NullableString structure.
The position of the substring within a.
A NullableString structure.
The position of the substring within b.
The maximum number of characters in the substrings to compare.
A Boolean indicating a case-sensitive or insensitive comparison. (true indicates a case-insensitive comparison).

Return Value

A 32-bit signed integer indicating the lexical relationship between the two comparands.

A negative integer the substring in a is less than the substring in b.
Zero the substring in a is equal to the substring in b.
A positive integer the substring in a is greater than the substring in b.


b is Null.


indexA and indexB are zero-based. length cannot be negative. If length is zero, then zero is returned. The number of characters compared is the lesser of the length of a less indexA, the length of b less indexB, and length. By definition, any NullableString, including the Empty string, compares greater than Null; and two Null compare equal to each other. This method performs a case-sensitive operation. The method uses the current culture to determine the ordering of individual characters. Uppercase letters evaluate greater than their lowercase equivalents. The two NullableString are compared on a character-by-character basis.


Exception TypeCondition
ArgumentOutOfRangeException The sum of indexA and length is greater than a.


The sum of indexB and length is greater than b.


indexA, indexB or length is negative.

See Also

NullableString Class | NullableTypes Namespace | NullableString.Compare Overload List