System.Globalization.CompareInfo.LastIndexOf Method

Searches for the specified substring and returns the zero-based index of the last occurrence within the entire source string.

Syntax

public virtual int LastIndexOf (string source, string value)

Parameters

source
The string to search.
value
The string to locate within source.

Returns

The zero-based index of the last occurrence of value, if found, within source; otherwise, -1.

Remarks

The source string is searched backward starting at the end of the string and ending at the beginning of the string.

This overload performs a culture-sensitive search. A Unicode value representing a precomposed character, such as the ligature "Æ" (U+00C6), might be considered equivalent to any occurrence of the character's components in the correct sequence, such as "AE" (U+0041, U+0045), depending on the culture. To perform an ordinal (culture-insensitive) search, where the Unicode values are compared, you should call one of the overloads that has a parameter of type System.Globalization.CompareOptions and use the CompareOptions.Ordinal value.

Note:

When possible, you should call string comparison methods that have a parameter of type System.Globalization.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 CompareOptions.Ordinal or CompareOptions.OrdinalIgnoreCase for security comparisons.

Requirements

Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0