title: Why does the using statement work on IEnumerator and what does it do?
body: <p>Back when I was learning about <code>foreach</code>, I read somewhere that this:</p>
  
  <pre><code>foreach (var element in enumerable)
  {
      // do something with element
  }
  </code></pre>
  
  <p>is basically equivalent to this:</p>
  
  <pre><code>using (var enumerator = enumerable.GetEnumerator())
  {
      while (enumerator.MoveNext())
      {
          var element = enumerator.Current;
  
          // do something with element
      }
  }
  </code></pre>
  
  <p>Why does this code even compile if neither <code>IEnumerator</code> nor <code>IEnumerator&lt;T&gt;</code> implement <code>IDisposable</code>? C# language specification only seems to mention the <code>using</code> statement in the context of <code>IDisposable</code>.</p>
  
  <p>What does such an <code>using</code> statement do?</p>