Troubles implementing IEnumerable

后端 未结 7 921
清酒与你
清酒与你 2020-11-29 11:08

I\'m trying to write my own (simple) implementation of List. This is what I did so far:

using System;
using System.Collections.Generic;
using System.Linq;
us         


        
7条回答
  •  余生分开走
    2020-11-29 11:24

    Read the error message more carefully; it is telling you exactly what you must do. You did not implement System.Collections.IEnumerable.GetEnumerator.

    When you implement the generic IEnumerable you have to also implement System.Collections.IEnumerable's GetEnumerator.

    The standard way to do so is:

    public IEnumerator GetEnumerator () { whatever }
    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
    {
        return this.GetEnumerator();
    }
    

提交回复
热议问题