Assuming I have the following string array:
string[] str = new string[] {\"max\", \"min\", \"avg\", \"max\", \"avg\", \"min\"}
Is it possbile t
You need a combined select and where operator, comparing to accepted answer this will be cheaper, since won't require intermediate objects:
public static IEnumerable SelectWhere(this IEnumerable source, Func filter, Func selector)
{
int index = -1;
foreach (var s in source)
{
checked{ ++index; }
if (filter(s))
yield return selector(s, index);
}
}