<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>To foreach or not to foreach that is the question.</title><link>http://blogs.msdn.com/b/kevin_ransom/archive/2004/04/19/116072.aspx</link><description>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 &amp;lt;</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>C#: The Dangers of Foreach</title><link>http://blogs.msdn.com/b/kevin_ransom/archive/2004/04/19/116072.aspx#8710370</link><pubDate>Wed, 09 Jul 2008 02:56:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8710370</guid><dc:creator>Technical Musings</dc:creator><description>&lt;p&gt;Although very handy, C#&amp;amp;#39;s foreach statement is actually quite dangerous. In fact, I may swear off its use entirely. Why? Two reasons: (1) performance, and (2) predictability....&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8710370" width="1" height="1"&gt;</description></item><item><title>re: [原创]如何改善Managed Code的Performance和Scalability系列之一：由for V.S. for each想到的</title><link>http://blogs.msdn.com/b/kevin_ransom/archive/2004/04/19/116072.aspx#4280478</link><pubDate>Tue, 07 Aug 2007 20:22:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4280478</guid><dc:creator>cnblogs.com</dc:creator><description>&lt;p&gt;事实上对Array进行foreach的时候根本不会调用GetEnumerator()方法, 也就是被编译器给内联了. 而对于List&amp;amp;lt;&amp;amp;gt;, 虽然没有编译器内联GetEnumerator()&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4280478" width="1" height="1"&gt;</description></item><item><title>for VS. foreach 那个性能更高，为什么，怎么选择</title><link>http://blogs.msdn.com/b/kevin_ransom/archive/2004/04/19/116072.aspx#4082930</link><pubDate>Fri, 27 Jul 2007 19:30:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4082930</guid><dc:creator>holyrong</dc:creator><description>&lt;p&gt;for和foreach 的效率问题是个老问题了，从网上看到的是众说纷纭，有说for效率高的也有说foreach效率高的，还有说测试方法有问题的；通过实验发现for的效率比foreach高。&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4082930" width="1" height="1"&gt;</description></item><item><title>Better Living through Software  &amp;raquo; Blog Archive   &amp;raquo; Loopy Decisions</title><link>http://blogs.msdn.com/b/kevin_ransom/archive/2004/04/19/116072.aspx#694422</link><pubDate>Thu, 10 Aug 2006 18:14:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:694422</guid><dc:creator>Better Living through Software  » Blog Archive   » Loopy Decisions</dc:creator><description>PingBack from &lt;a rel="nofollow" target="_new" href="http://www.netcrucible.com/blog/2004/04/21/loopy-decisions-2/"&gt;http://www.netcrucible.com/blog/2004/04/21/loopy-decisions-2/&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=694422" width="1" height="1"&gt;</description></item><item><title>Better Living through Software  &amp;raquo; Blog Archive   &amp;raquo; Loopy Decisions</title><link>http://blogs.msdn.com/b/kevin_ransom/archive/2004/04/19/116072.aspx#694419</link><pubDate>Thu, 10 Aug 2006 18:14:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:694419</guid><dc:creator>Better Living through Software  » Blog Archive   » Loopy Decisions</dc:creator><description>PingBack from &lt;a rel="nofollow" target="_new" href="http://www.netcrucible.com/blog/2004/04/21/loopy-decisions/"&gt;http://www.netcrucible.com/blog/2004/04/21/loopy-decisions/&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=694419" width="1" height="1"&gt;</description></item><item><title>'for' vs 'foreach'</title><link>http://blogs.msdn.com/b/kevin_ransom/archive/2004/04/19/116072.aspx#426003</link><pubDate>Tue, 07 Jun 2005 11:10:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:426003</guid><dc:creator>- TrIpLeZoNe -</dc:creator><description>Here are some resources to read up on the differences between 'for' and 'foreach'.&lt;br&gt;Enumerating array...&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=426003" width="1" height="1"&gt;</description></item><item><title>re: foreach Row in ...</title><link>http://blogs.msdn.com/b/kevin_ransom/archive/2004/04/19/116072.aspx#270360</link><pubDate>Thu, 25 Nov 2004 19:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:270360</guid><dc:creator>Andrea Piccoli's blog</dc:creator><description>&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=270360" width="1" height="1"&gt;</description></item><item><title>I think I got it now</title><link>http://blogs.msdn.com/b/kevin_ransom/archive/2004/04/19/116072.aspx#249550</link><pubDate>Fri, 29 Oct 2004 16:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249550</guid><dc:creator>dotRob</dc:creator><description>&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=249550" width="1" height="1"&gt;</description></item><item><title>I think I got it now</title><link>http://blogs.msdn.com/b/kevin_ransom/archive/2004/04/19/116072.aspx#248077</link><pubDate>Tue, 26 Oct 2004 23:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:248077</guid><dc:creator>Omer van Kloeten's .NET Zen</dc:creator><description>&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=248077" width="1" height="1"&gt;</description></item><item><title>Eric Gunnerson on Loops</title><link>http://blogs.msdn.com/b/kevin_ransom/archive/2004/04/19/116072.aspx#131997</link><pubDate>Fri, 14 May 2004 19:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:131997</guid><dc:creator>Bryant Likes's Blog</dc:creator><description>&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=131997" width="1" height="1"&gt;</description></item></channel></rss>