How to

use IEnumerator

Published: 9. October 2011 | Updated: 9. October 2011
License: Microsoft Public License (MS-PL)
Categories: Collections
Tags: C# Collections
Was this snippet helpful for you? YESYES / NONO

Import namespace

using System.Collections;

Code

var collection = new[] { 1, 2, 3, 4, 5 };

IEnumerator enumerator = collection.GetEnumerator();

while (enumerator.MoveNext())
{
    Console.WriteLine(enumerator.Current);
}
Console Output:
1
2
3
4
5
Send us feedback about this snippet »



Related Snippets: