link能不能直接调用方法?还是只能写表达式?
int[] array = { 1, 2, 3, 4, 5, 6, 7, 8 };
var query = from x in array
where Predicate
select x;
foreach (int item in query)
Console.WriteLine(item);
bool Predicate(int n)
{
if (n % 2 == 0)
return true;
return false;
}
为什么不行?
int[] array = { 1, 2, 3, 4, 5, 6, 7, 8 };
var query = from x in array
where Predicate(x)
select x;
这样写也可以。注意是调用方法,不是传方法。