开发者

Would there be any performance difference between these 2 IEnumerable<T> codes using foreach?

开发者 https://www.devze.com 2023-02-08 22:57 出处:网络
var effects = this.EffectsRecursive; foreach ( Effect effect in effects ) { ... } vs 开发者_开发知识库foreach ( Effect effect in this.EffectsRecursive )
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.

0

精彩评论

暂无评论...
验证码 换一张
取 消