标签: c# .net performance ienumerable
var effects = this.EffectsRecursive; foreach ( Effect effect in effects ) { ... }
VS
foreach ( Effect effect in this.EffectsRecursive ) { ... }
答案 0 :(得分:10)
不,foreach根据调用IEnumerable.GetEnumerator的结果进行操作,无论哪种方式都会调用它。
IEnumerable.GetEnumerator