IEnumerator : Generic IEnumerator « Generic « C# / CSharp Tutorial






using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;

public class MainClass
{
    public static void Main()
    {
        IEnumerable<string> enumerable = new string[] { "A", "B", "C" };

        foreach (string s in enumerable)
            Console.WriteLine(s);

        IEnumerator<string> enumerator = enumerable.GetEnumerator();
        while (enumerator.MoveNext())
        {
            string s = enumerator.Current;
            Console.WriteLine(s);
        }
    }
}
A
B
C
A
B
C








18.10.Generic IEnumerator
18.10.1.IEnumerator
18.10.2.Creating a list from an array
18.10.3.A generic iterator.
18.10.4.Generic IEnumerator/IEnumerable
18.10.5.Template method