title: When should I use IEnumerator for looping in c#?
body: <p>I was wondering if there are any times where it's advantageous to use an IEnumerator over a foreach loop for iterating through a collection? For example, is there any time where it would be better to use either of the following code samples over the other?</p>
  
  <pre><code>IEnumerator&lt;MyClass&gt; classesEnum = myClasses.GetEnumerator();
  while(classesEnum.MoveNext())
      Console.WriteLine(classesEnum.Current);
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>foreach (var class in myClasses)
      Console.WriteLine(class);
  </code></pre>