LINQ is elegant… and allocates.
Problem
-
Deferred execution
-
Hidden enumerators
Fix
Use LINQ at boundaries, not inside loops.
for (int i = 0; i < list.Count; i++)
{
Process(list[i]);
}
Why
Predictable execution beats elegance under load.
