C# String LastIndexOf(String)
Description
String LastIndexOf(String)
reports the zero-based
index position of the last occurrence of a specified string within this instance.
Syntax
String.LastIndexOf(String)
has the following syntax.
public int LastIndexOf(
string value
)
Parameters
String.LastIndexOf(String)
has the following parameters.
value
- The string to seek.
Returns
String.LastIndexOf(String)
method returns The zero-based starting index position of value if that string is found,
or -1 if it is not. If value is String.Empty, the return value is the last index
position in this instance.
Example
using System;//w w w .j a v a 2 s .co m
public class Example
{
public static void Main()
{
string s1 = "ani\u00ADmal";
string s2 = "animal";
// Find the index of the last soft hyphen.
Console.WriteLine(s1.LastIndexOf("\u00AD"));
}
}
The code above generates the following result.