Would there be any performance difference between these 2 IEnumerable<T> codes using foreach?
var effects = this.EffectsRecursive;
foreach ( Effect effect in effects )
{
...
}
vs
开发者_开发知识库foreach ( Effect effect in this.EffectsRecursive )
{
...
}
No, the foreach operates on the result of the call to IEnumerable.GetEnumerator
, which will get called only once either way.
精彩评论