When IEnumerator.Reset() method is called?

后端 未结 6 593
醉话见心
醉话见心 2021-01-11 14:51

let\'s have this code :

class MyList : IEnumerable, IEnumerator
{
    int[] A = { 1, 2, 3, 4, 5 };
    int i = -1;

    #region IEnumerator Members

    pub         


        
6条回答
  •  粉色の甜心
    2021-01-11 15:34

    This also works:

    public bool MoveNext()
    {
            if(i < 5)
            {
                i++;
                return true;
            }
            else
            {
                i = -1;
                return false;
            }
    }
    

提交回复
热议问题