IEnumerator

  用于遍历一个对象,IEnumerator在System.Collections命名空间中。

    public interface IEnumerator
    {
        object Current
        {
            get;
        }

        bool MoveNext ();
        void Reset ();
    }

IEnumerable

  用于遍历一个对象是否能被遍历,IEnumerable在System.Collections命名空间中。

    public interface IEnumerable
    {
        IEnumerator GetEnumerator ();
    }

  一个对象如何被foreach进行迭代,必须实现上述2个interface。

参考:

1、http://msdn.microsoft.com/zh-cn/library/58e146b7(v=vs.80).aspx

2、http://blog.csdn.net/byondocean/article/details/6871881

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-24
  • 2022-12-23
  • 2022-01-13
猜你喜欢
  • 2021-10-26
  • 2022-02-22
  • 2021-10-11
  • 2021-05-24
相关资源
相似解决方案