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

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

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

Dictionary implements IEnumerable

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-08 13:28

    Add the following explicit interface implementation:

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

    Although IEnumerator is an IEnumerator, the contract for IEnumerable returns an IEnumerator specifically, not an IEnumerator

提交回复
热议问题