I think I got it now

I think I get it now: foreach is ok for static arrays, but bad for everything else (look at #5 on the list).

Oh. :)

They say it would be fixed in vnext, though.

On a side note, remember to never ever take for over foreach if you can use the enumerator to enumerate on your list at O(1), like in a linked list, where index-based enumeration would be a large perf hit.
Pretty simple, but keep it in mind. :)


One thought on “I think I got it now

  1. foreach is OK for 99% of code that is every written, most code does not need to be very fast. Normal programmers, (the sort that do not work for Microsoft) write software then spends 90% of it’s time waiting for the RDBMS, so the speed of the other 10% is often not important.

    ringi at bigfoot dot com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s