Kevin RansomDeveloping the Peer ChannelTo foreach or not to foreach that is the question.- April 19, 2004 Recently email was forwarded to me with a link to a page with some performance tips for developers. The second performance tip on the page was: foreach foreach through an array is incredibly slow compared to for (int i = 0; i < array.Length; i) This one leapt out at me because it is well ... not to put too fine a point on it ... wrong! (at least that is what I thought). C and Visual Basic 7 both contain specific optimizations to ensure that foreach on arrays...http://blogs.msdn.com/kevin_ransom/archive/2004/04/19/116072.aspx |