Mono Class Library: System.String Overview | MembersSystem.String.LastIndexOf Method |
Returns the index of the last occurrence of a specified character within the current instance. [Edit]
|
A int containing the index of the last occurrence of value in the current instance, if found; otherwise, -1. [Edit]
Type Reason ArgumentNullException value is a null reference. [Edit] ArgumentOutOfRangeException startIndex is less than zero or greater than the length of the current instance. [Edit]
This method searches for the last occurrence of the specified character between the start of the string and the indicated index.
This method is case-sensitive.
[Edit]
The following example demonstrates the string.LastIndexOf(char) method.
C# Example using System; public class StringLastIndexOfTest { public static void Main() { String str = "aa bb cc dd"; Console.WriteLine( str.LastIndexOf('d', 8) ); Console.WriteLine( str.LastIndexOf('b', 8) ); } }The output is
-1
4
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0