Enumerator Basics c#



An enumerated type is declared using the enum keyword. C# enumerations are value data types.

using System;
using System.Collections;

namespace CSharpCollection
{
    class EnumeratorBasics
    {
		static void Main()
		{
			int[] MyArray = { 10, 11, 12, 13 }; // Create an array.
			IEnumerator ie = MyArray.GetEnumerator();

			while ( ie.MoveNext() )
			{
				int i = (int) ie.Current;
				Console.WriteLine("{0}", i); // Write it out.
			}
		}
    }
}

0 Comment's

Comment Form