Performance of the Loops … in C#
4 min readJun 4, 2017
As strange as one might think, the topic of the performance of loops in C# is not that trivial. I am talking here about high performance applications where every millisecond counts.
Looping over an Array
Consider an array of 100 millions integers, that you want to scan as fast as you can. What would be the right way to do it ?
C# provides several ways to loop over an array or a collection:
- for, while
- foreach
- Array.ForEach()