How do I implement IEnumerable in my Dictionary wrapper class that implements IEnumerable?

后端 未结 7 2209
走了就别回头了
走了就别回头了 2021-02-08 12:56

I\'m trying to create a wrapper for a Dictionary.

Dictionary implements IEnumerable

7条回答
  •  佛祖请我去吃肉
    2021-02-08 13:45

    As long as generic IEnumerable{T} inherit IEnumerable You have to implement IEnumerable.GetEnumerator() as well. You can do it explicitly like:

    IEnumerator IEnumerable.GetEnumerator()
    {
           return GetEnumerator();
    }
    

提交回复
热议问题