C#StringLastIndexOf
IndexOf

LastIndexOfString

Insert

Returns the zero-based index of the last occurrence of a value.

Syntax

str.LastIndexOf(value)

Example

Enter values below to update the example in real time.

string
idx
LastIndexOf
Console
WriteLine
string text = "Hello World Hello";
int idx = text.LastIndexOf("Hello");
Console.WriteLine(idx);   // 12