Troubles implementing IEnumerable

后端 未结 7 905
清酒与你
清酒与你 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:31

    There are two overloads of GetEnumerator() that you must implement. One comes from IEnumerable and returns IEnumerator. The other comes from IEnumerable and returns IEnumerator. The override should look like this:

    IEnumerator IEnumerable.GetEnumerator()

    This is because IEnumerable implements IEnumerable.

提交回复
热议问题