Welcome

首页 / 软件开发 / 数据结构与算法 / DotNet Framework源代码中的模式(三)——Iteartor(迭代器模式)

DotNet Framework源代码中的模式(三)——Iteartor(迭代器模式)2012-01-05 博客园 guushuuse提供一种方法顺序访问一个聚合对象中各个元素,而又不需暴露该对象的内部表示。

以.NET Framework 2.0 System.Collections中类为例

System.Collections. IEnumerable

public interface IEnumerable{    IEnumerator GetEnumerator();}
System.Collections.ICollection

public interface ICollection : IEnumerable{    int Count { get; }    bool IsSynchronized { get; }    object SyncRoot { get; }    void CopyTo(Array array, int index);}