C# String LastIndexOf(String, StringComparison)
Description
String LastIndexOf(String, StringComparison)
reports
the zero-based index of the last occurrence of a specified string within
the current String object. A parameter specifies the type of search to use
for the specified string.
Syntax
String.LastIndexOf(String, StringComparison)
has the following syntax.
public int LastIndexOf(
string value,
StringComparison comparisonType
)
Parameters
String.LastIndexOf(String, StringComparison)
has the following parameters.
value
- The string to seek.comparisonType
- One of the enumeration values that specifies the rules for the search.
Returns
String.LastIndexOf(String, StringComparison)
method returns The zero-based starting index position of the value parameter 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
In the following example, the LastIndexOf(String, StringComparison) method is used.
//w ww. j a va2s . c o m
using System;
public class Example
{
public static void Main()
{
string s1 = "ani\u00ADmal";
string s2 = "animal";
Console.WriteLine(s1.LastIndexOf("\u00AD", StringComparison.CurrentCulture));
}
}
The code above generates the following result.