Android Guides | Samples

Java.Lang.String.CompareToIgnoreCase Method

Compares this string to the given string, ignoring case differences.

Syntax

[Android.Runtime.Register("compareToIgnoreCase", "(Ljava/lang/String;)I", "")]
public Int32 CompareToIgnoreCase (String string)

Parameters

string
the string to compare.

Exceptions

TypeReason
NullPointerExceptionif string is null.

Remarks

Compares this string to the given string, ignoring case differences.

The strings are compared one char at a time. This is not suitable for case-insensitive string comparison for all locales. Use a Collator instead.

If there is an index at which the two strings differ, the result is the difference between the two chars at the lowest such index. If not, but the lengths of the strings differ, the result is the difference between the two strings' lengths. If the strings are the same length and every char is the same, the result is 0.

[Android Documentation]

Requirements

Namespace: Java.Lang
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1