如果我有一个集合:
List<T> collection;
我需要对这个集合执行两个测试,这样效率更高:
foreach(T t in collection.where(w => w.value == true))
{
     t.something = true;
}
foreach(T t in collection.where(w => w.value2 == true))
{
     t.something2 = true;
}
或者
foreach(T t in collection)
{
 if (t.value == true)
  {
     //check 1
  }
  if (t.value2 == true)
  {
    //check 2
  }
}
我认为会是后者,因为我假设每个where人都会迭代集合,但只是想确保我没有遗漏什么?