Exemplo n.º 1
0
        /// <summary>
        /// 迭代器模式
        /// </summary>
        public static void IteratorPatternMethods()
        {
            ConcreteList concreteList = new ConcreteList();
            var          iterator     = concreteList.GetIterator();

            while (iterator.MoveNext())
            {
                Console.WriteLine(iterator.GetCurrent());
                iterator.Next();
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            IListCollection list     = new ConcreteList();
            Iterator        iterator = list.GetIterator();

            while (iterator.MoveNext())
            {
                int i = (int)iterator.GetCurrent();
                Console.WriteLine(i.ToString());
                iterator.Next();
            }

            Console.Read();
        }