New version of doing a for loop?
<p>I understand there is now a new way to write <code>for</code> loops using <code>foreach</code>? I am using <strong>c#</strong> and <strong>Visual Studio 2015</strong>.</p>

<p>Here is the current loop:</p>

<pre><code>for(int iCodeLength = 4; iCodeLength &gt;= 1; iCodeLength--)
{
    if(xmlGenioCodes.SelectSingleNode(String.Format("GenioCodes[Code =\"{0}\"]", strCodeMX.Substring(0, iCodeLength))) != null)
    {
        strCodeMXLayer = strCodeMX.Substring(0, iCodeLength);
        break;
    }
}
</code></pre>

<p>What is the new way I can write the same <code>for</code> loop definition using <code>foreach</code>? And could you direct me to a good webpage that explains it as I not know what to search for.</p>

<p>Thank you!</p>