title: How to implement for-else and foreach-else in C# similar to Python's for-else and while-else?
body: <p>Python's <em>for</em> and <em>while</em> loops include an optional <em>else</em> clause which execute if the loop exits normally (<em>i.e.</em> without a <em>break</em> statement). For example, in Python you could code:</p>
  <pre><code>for x in range(3):
      print(x)
  else
      print(&quot;The loop exited normally&quot;)
  </code></pre>
  <p>And the output will be:</p>
  <pre><code>0
  1
  2
  The loop exited normally
  </code></pre>
  <p>How would you accomplish something similar in C# in order to code something like the following:</p>
  <pre><code>for (int i = 0; i &lt; 3; i++)
  {
      Console.WriteLine(x);                  
  }
  else
      Console.WriteLine(&quot;The loop exited normally&quot;);
  </code></pre>