您的位置:首页 > 其它

Iterator 提供一种方法顺序访问一个对象中各个元素,而又不需要暴露该对象的内部表示

2007-01-17 11:57 417 查看
using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Gof.Test.Iterator
6
using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Gof.Test.Iterator
6using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Gof.Test.Iterator
6using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Gof.Test.Iterator
6 ConcreteAggregate a = new ConcreteAggregate();
2 a[0] = "0";
3 a[1] = "00";
4 a[2] = "000";
5 a[3] = "0000";
6 a[4] = "00000";
7 a[5] = "000000";
8
9 ConcreteIterator i = new ConcreteIterator(a);
10
11 Console.WriteLine("begin");
12
13 object item = i.First();
14
15 while (item != null)
16
21 Console.ReadKey();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐