C#在预见中重用变量有什么原因吗?
foreach (var s in strings){ query = query.Where(i => i.Prop == s); // access to modified closure ...}
Where
s
.
s
foreach
string s;while (enumerator.MoveNext()){ s = enumerator.Current; ...}
while (enumerator.MoveNext()){ string s; s = enumerator.Current; ...}
string s;while (enumerator.MoveNext()){ s = enumerator.Current; ...}var finalString = s;
foreach
foreach(string s in strings){}var finalString = s; // won't work: you're outside the scope.
foreach
婷婷同学_
跃然一笑