Program.cs 627 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace IteratorPattern
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. Console.WriteLine("迭代器模式:");
  13. IListCollection list = new ConcreteList();
  14. var iterator = list.GetIterator();
  15. while (iterator.MoveNext())
  16. {
  17. int i = (int)iterator.GetCurrent();
  18. Console.WriteLine(i.ToString());
  19. iterator.Next();
  20. }
  21. Console.Read();
  22. }
  23. }
  24. }