123456789101112131415161718192021222324252627 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace IteratorPattern
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("迭代器模式:");
- IListCollection list = new ConcreteList();
- var iterator = list.GetIterator();
- while (iterator.MoveNext())
- {
- int i = (int)iterator.GetCurrent();
- Console.WriteLine(i.ToString());
- iterator.Next();
- }
- Console.Read();
- }
- }
- }
|