I took the following example from Jrista’s answer to a post.
Finding Twentyone count
int[] numbers = new[] { 1, 3, 11, 21, 9, 23, 7, 4, 18, 7, 7, 3, 21 };
var twentyoneCount = numbers.Where(n => n == 21).Count();
Suppose i use “Func” delegate how can i get the count ?
I tried as (pardon me for the bad syntax)
var otherway= Func <int> numbers= x => x==21;
You are using an anonymous delegate with the same signature as
Func<int, bool>right now. If you wanted to use a method instead, you could write:And then use it as: