Click or drag to resize
StringLastIndexOf Method (String, Int32, StringComparison)
Reports the zero-based index of the last occurrence of a specified string within the current String object. Parameters specify the starting search position in the current string, and type of search to use for the specified string.

Namespace: System
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public int LastIndexOf(
	string value,
	int startIndex,
	StringComparison comparisonType
)

Parameters

value
Type: SystemString
The string to seek.
startIndex
Type: SystemInt32
The search starting position. The search proceeds from startIndex toward the beginning of this instance.
comparisonType
Type: SystemStringComparison
One of the enumeration values that specifies the rules for the search.

Return Value

Type: Int32
The index position of the value parameter if that string is found, or -1 if it is not found or if the current instance equals Empty. If value is Empty, the return value is the smaller of startIndex and the last position in this instance.
Exceptions
ExceptionCondition
ArgumentNullExceptionvalue is null.
ArgumentOutOfRangeExceptionThe current instance does not equal Empty, and startIndex is less than zero or greater than the length of the current instance.-or-The current instance equals Empty, and startIndex is greater than zero.
ArgumentExceptioncomparisonType is not a valid StringComparison value.
See Also