public void Print <T>(IAggregate <T> aggregate) where T : MenuItem { Console.WriteLine(new string('_', 20)); var iterator = aggregate.GetIterator(); while (iterator.IsDone()) { Console.WriteLine(iterator.Current()); } Console.WriteLine(new string('_', 20)); }
static void Main(string[] args) { MyAg collection = new MyAg(); IAggregate my = (IAggregate)collection; IIterator itterator = my.GetIterator(); while (!itterator.IsDone) { Console.WriteLine(itterator.NextItem); } Console.ReadKey(); }