Returns the index of the last occurrence of the string in the current instance.
[Visual Basic] Overloads Public Function LastIndexOf( _ ByVal value As String, _ ByVal startIndex As Integer _ ) As Integer [C#] public int LastIndexOf( string value, int startIndex ); [C++] public: int LastIndexOf( String* value, int startIndex ); [JScript] public function LastIndexOf( value : String, startIndex : int ) : int;
Value | Condition |
---|---|
The index in the string | If the string is found. |
-1 | If the string is not found. |
Exception Type | Condition |
---|---|
ArgumentNullException | If the string is null. |
ArgumentOutOfRangeException | If the starting position is less than zero or greater than the length of the string. |
The LastIndexOf method returns the position of the last instance of the specified character array in the string from a specified starting position. This string is traversed backwards from right to left, beginning at startIndex. The character at position startIndex is included in the search. The search is case-sensitive.
String Class | String Members | System Namespace | String.LastIndexOf Overload List | Int32