I have been told that there is a performance difference between the following code blocks.
foreach (Entity e in entityList)
{
....
}
and <
The foreach sample roughly corresponds to this code:
using(IEnumerator e = entityList.GetEnumerator()) {
while(e.MoveNext()) {
Entity entity = e.Current;
...
}
}
There are two costs here that a regular for loop does not have to pay: