Esempio n. 1
0
        static void Execute()
        {
            // 自己实现的iterator
            ProductList productList = new ProductList();

            productList.AddObject("建造者模式");
            productList.AddObject("工厂方法模式");
            productList.AddObject("职责链模式");
            productList.AddObject("抽象工厂模式");
            productList.AddObject("解释器模式");
            IIterator iterator = productList.CreateIterator();

            while (iterator.GetNextItem() is string item)
            {
                iterator.MoveToNext();
                Console.WriteLine(item);
            }
        }