Search by predicate and return the index within range that starts at index and contains the number of elements in CSharp
Description
The following code shows how to search by predicate and return the index within range that starts at index and contains the number of elements.
Example
/* www . ja v a2 s . c o 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.FindIndex(myValues, 0, 3, myPredicate));
}
private static bool LenCheck(String s)
{
if (s.Length > 3)
{
return true;
}
else
{
return false;
}
}
}
The code above generates the following result.