Should the same code the compiler uses be used in production code?
<p>I was reading this recent post by Jon Skeet: <a href="http://msmvps.com/blogs/jon_skeet/archive/2012/09/30/how-can-i-enumerate-thee-let-me-count-the-ways.aspx?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+JonSkeetCodingBlog+%28Jon+Skeet%27s+Coding+Blog%29" rel="nofollow">How can I enumerate thee? Let me count the ways...</a>. It is about investigating what code compiles into. In this case, he examines </p>

<pre><code>foreach (char ch in text) 
{ 
 // Body here 
}
</code></pre>

<p>The final example he uses (for the case when text is of type <code>string</code>), he shows that the compiler converts the foreach loop into a while loop like this:</p>

<pre><code>int index = 0; 
while (index &lt; text.Length) 
{ 
 char ch = text[index]; 
 index++; 
 // Body here 
}
</code></pre>

<p>In this case, it may not be much of an effort to convert from the foreach loop to a while loop (or even necessary to make that conversion), but in a more general sense, should I be writing my code to be more similar to compiled code?</p>
