Search by predicate and returns index of the last occurrence within the range from specified start and end in CSharp
Description
The following code shows how to search by predicate and returns index of the last occurrence within the range from specified start and end.
Example
/*from www. j a v a2 s. co m*/
using System;
public class MainClass
{
public static void Main()
{
string[] myValues ={
"1234", "19", "3456",
"3456", "200","5678",
"6543", "9876"
};
Predicate<string> myPredicate = LenCheck;
Console.WriteLine(Array.FindLastIndex(myValues,0,1, myPredicate));
}
private static bool LenCheck(String s)
{
if (s.Length > 3)
{
return true;
}
else
{
return false;
}
}
}
The code above generates the following result.