Not always — but when it matters, it matters.
Reason
-
Enumerator allocations
-
Interface dispatch
-
Bounds checks differ
Critical paths
Use for on arrays and spans.
for (int i = 0; i < arr.Length; i++)
{
Process(arr[i]);
}
Daily micro-tips for C#, SQL, performance, and scalable backend engineering.
Not always — but when it matters, it matters.
Reason
Enumerator allocations
Interface dispatch
Bounds checks differ
Critical paths
Use for on arrays and spans.
for (int i = 0; i < arr.Length; i++)
{
Process(arr[i]);
}