Hunny Software Library Reference

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

Compares substrings of two byte strings, with case-insensitive option.

[Visual Basic]
Overloads Public Shared Function Compare( _
   ByVal str1 As ByteString, _
   ByVal index1 As Integer, _
   ByVal str2 As ByteString, _
   ByVal index2 As Integer, _
   ByVal count As Integer, _
   ByVal ignoreCase As Boolean _
) As Integer
[C#]
public static int Compare(
   ByteString str1,
   int index1,
   ByteString str2,
   int index2,
   int count,
   bool ignoreCase
);

Parameters

str1
first byte string
index1
position of the substring in str1
str2
second byte string
index2
position of the substring in str2
count
maximum number of charcters to compare
ignoreCase
if true, comparison is case-insensitive

Return Value

negative value if the first substring precedes the second in lexical ordering;
positive value if the first substring follows the second in lexical ordering;
zero otherwise

Remarks

If ignoreCase is true, the result is equivalent to performing a case-sensitive comparison after converting the uppercase ASCII letters A-Z in both byte strings to lowercase.

This method is frequently used with ignoreCase true to compare a byte string to a MIME "keyword", such as "Content-Type", where the byte string's content is known to be ASCII characters.

null is a valid argument that always precedes a byte string in the lexical ordering (that is, it's "less than" a byte string).

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionindex1 < 0,
or index2 < 0,
or count < 0,
or index1 + count > str1.Length
or index2 + count > str2.Length

See Also

ByteString Class | Hunny.Base Namespace | ByteString.Compare Overload List