示例#1
0
 private DuckFlock CreateTestFlock()
 {
     DuckFlock flock = new DuckFlock();
     flock.Add(new MallardDuck { Name = "Fred the Mallard" });
     flock.Add(new MandarinDuck { Name = "Aaron the Mandarin" });
     return flock;
 }
示例#2
0
 // Iterator pattern with aggregate
 void iterateMyDucks_Click(object sender, EventArgs e)
 {
     DuckFlock flock = new DuckFlock();
     flock.Add(new MallardDuck());
     flock.Add(new MandarinDuck());
     flock.Add(new RubberDuck());
     LoopThroughDucksUsingIterator(flock);
 }