using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Iterator { internal class CommonIterator : IIterator { private object[] collection; private int index; public CommonIterator(object[] collection) { this.collection = collection; this.index = -1; } public bool HasNext { get { return index + 1 < collection.Length; } } public object Next() { if (HasNext) { index++; return collection[index]; } else { return null; } } } }