Example

using System;
using System.Collections;

namespace Samples
{
  public class IEnumeratorSample
  {
    public static void Main()
    {
      IEnumerable s = "Hello world";
      IEnumerator ie = s.GetEnumerator();
      while(ie.MoveNext())
        Console.Write(ie.Current);
      Console.WriteLine();
      ie.Reset();
      while(ie.MoveNext())
        Console.Write(ie.Current);
    }
  }
}
The output is
Hello world
Hello world

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.