Using One of the Func Delegate Declarations
using System; using System.Collections.Generic; using System.Linq; class Program// w ww . j a va 2 s . c o m { static void Main(string[] args) { // Create an array of ints. int[] ints = new int[] { 1,2,3,4,5,6 }; // Declare our delegate. Func<int, bool> GreaterThanTwo = i => i > 2; // Perform the query ... not really. Don't forget about deferred queries!!! IEnumerable<int> intsGreaterThanTwo = ints.Where(GreaterThanTwo); // Display the results. foreach(int i in intsGreaterThanTwo) Console.WriteLine(i); } }