我根据每个内部的两个不同条件设置两个值。是否可以在LINQ中实现以下内容?
foreach(Customer cust in Customers)
{
If(Condition 1)
condtion1Var =true;
If(Condition2 )
condition2Var =true;
}
答案 0 :(得分:2)
condition1Result = customers.Any(cust => Condition1(cust));
condition2Result = customers.Any(cust => Condition2(cust));