July 2008 Archives

C#: The Dangers of Foreach

July 8, 2008

Although very handy, C#'s foreach statement is actually quite dangerous. In fact, I may swear off its use entirely. Why? Two reasons: (1) performance, and (2) predictability.