LINQ实现查询?

时间:2009-10-26 15:14:52

标签: linq linq-to-objects

我根据每个内部的两个不同条件设置两个值。是否可以在LINQ中实现以下内容?

foreach(Customer cust in Customers)
{
    If(Condition 1)
            condtion1Var =true;
    If(Condition2 )
            condition2Var =true;
}

1 个答案:

答案 0 :(得分:2)

condition1Result = customers.Any(cust => Condition1(cust));
condition2Result = customers.Any(cust => Condition2(cust));