C# String LastIndexOfAny(Char[])
Description
String LastIndexOfAny(Char[])
reports the zero-based
index position of the last occurrence in this instance of one or more characters
specified in a Unicode array.
Syntax
String.LastIndexOfAny(Char[])
has the following syntax.
public int LastIndexOfAny(
char[] anyOf
)
Parameters
String.LastIndexOfAny(Char[])
has the following parameters.
anyOf
- A Unicode character array containing one or more characters to seek.
Returns
String.LastIndexOfAny(Char[])
method returns The index position of the last occurrence in this instance where any character
in anyOf was found; -1 if no character in anyOf was found.
Example
Sample for String.LastIndexOfAny(Char[])
/* w w w.j a v a 2s. co m*/
using System;
class Sample {
public static void Main() {
string str = "this is a test.";
string target = "is";
char[] anyOf = target.ToCharArray();
int start = str.Length-1;
int at = str.LastIndexOfAny(anyOf);
if (at > -1)
Console.Write(at);
else
Console.Write("(not found)");
}
}
The code above generates the following result.