title: How is foreach implemented in C#?
body: <p>How exactly is <code>foreach</code> implemented in C#?</p>
  
  <p>I imagine a part of it looking like:</p>
  
  <pre><code>var enumerator = TInput.GetEnumerator();
  while(enumerator.MoveNext())
  {
    // do some stuff here
  }
  </code></pre>
  
  <p>However I'm unsure what's really going on. What methodology is used for returning <code>enumerator.Current</code> for each cycle? Does it return [for each cycle] or does it take an anonymous function or something to execute the body of <code>foreach</code>?</p>