我想澄清我对 LINQ 的疑问。我有如下代码:
val collection = this.Employees.Where(emp => emp.IsActive)
foreach (var emp in collection)
{
// some stuff
}
现在如果我写这样的代码:
foreach (var emp in this.Employees.Where(emp => emp.IsActive))
{
// some stuff
}
每次迭代都会this.Employees.Where(emp => emp.IsActive)
执行还是只执行一次?