Codeint[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
对此数组进行查询,查询小于5的数:
var lowNus = from n in numbers where n < 5 select n;
Func<int, bool> ourfunc = delegate(int n) { return n < 5; };
var lowNus = numbers.Where(ourfunc);
Func<int, bool> myfunc = n => n < 5;
var lowNus = numbers.Where(myfunc );
Expression<Func<int, bool>> exp = n => n < 5;
var lowNus = numbers.Where(exp.Compile());
以上方法的输出结果: