+5  A: 

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:

// a method that takes int and returns bool is
// a Func<int, bool> delegate
public bool IsEqualTo21(int x)
{ 
    return (x == 21);
}

And then use it as:

var twentyoneCount = numbers.Where(IsEqualTo21).Count();
Groo
+1  A: 

Maybe something like:

Func<bool, int, int[]> method = MyMethod

int[] numbers = new[] { 1, 3, 11, 21, 9, 23, 7, 4, 18, 7, 7, 3, 21 };
int count = method(21, numbers);


private bool MyMethod(int numberToCheck, int[] numbers)
{
    int count = 0;
    foreach (var number in numbers)
    {
        if (number == numberToCheck)
            {
                count++;
            }
    }
    return count;
}
Peter
Well, if you are using a delegate, then I would recommend sticking with LINQ to do the actual iteration, and only implement the test in a delegate.
Groo
+2  A: 
 int[] numbers = new[] { 1, 3, 11, 21, 9, 23, 7, 4, 18, 7, 7, 3, 21 };
 int twentyoneCount = numbers.Count(delegate(int i)
 {
     return (i == 21);
 });
Mehdi Golchin
This being the C# 2.0 form of the syntax -- the "n => n == 21" style simply being syntactic sugar for exactly what you have written.
Steve Gilham
A: 

Also this

var numbers = new[] { 1, 3, 11, 21, 9, 23, 7, 4, 18, 7, 7, 3, 21 }; numbers.Count(i => (i == 21));

Florim Maxhuni