
Untitled
By: a guest on
May 2nd, 2012 | syntax:
None | size: 0.77 KB | hits: 10 | expires: Never
using System;
using System.Linq;
namespace CollectionsExtensions
{
public class Program
{
public static void Main()
{
var array = new [] { 1, 3, 5, 7, 11, 13, 17, 19 };
// ridiculous example - since this could be simplified
// by using foreach and an enumerator.
var iterator = array.GetIterator();
while (iterator.HasCurrent)
{
Console.WriteLine(iterator.Current);
iterator.MoveNext();
}
iterator = Enumerable.Empty<int>().GetIterator();
while (iterator.HasCurrent)
{
Console.WriteLine(iterator.Current);
iterator.MoveNext();
}
}
}
}