In .NET, which loop runs faster, 'for' or 'foreach'?

前端 未结 30 1400
抹茶落季
抹茶落季 2020-11-22 04:25

In C#/VB.NET/.NET, which loop runs faster, for or foreach?

Ever since I read that a for loop works faster than a foreach

30条回答
  •  太阳男子
    2020-11-22 04:50

    My guess is that it will probably not be significant in 99% of the cases, so why would you choose the faster instead of the most appropriate (as in easiest to understand/maintain)?

提交回复
热议问题