Search by predicate and returns index within a range in CSharp
Description
The following code shows how to search by predicate and returns index within a range.
Example
using System;/*from w ww . j a v a 2s . com*/
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, myPredicate));
}
private static bool LenCheck(String s)
{
if (s.Length > 3)
{
return true;
}
else
{
return false;
}
}
}
The code above generates the following result.