最佳答案
我在日常生活中写了相当多的 LINQ,但大部分都是简单的陈述。我已经注意到,当使用 where
子句时,有许多方法来写它们,而且就我所知,每种方法都有相同的结果。例如:
from x in Collection
where x.Age == 10
where x.Name == "Fido"
where x.Fat == true
select x;
至少就结果而言,似乎与此相当:
from x in Collection
where x.Age == 10 &&
x.Name == "Fido" &&
x.Fat == true
select x;
那么,除了语法之外,真的还有区别吗? 如果有,首选的样式是什么? 为什么?