[When I tried posting this there was an error, I apologize if this is a
duplicate.]
Something I found surprising this week involves the IEnumerable<Tinterface.
I have a class that I wrote a couple of years ago which implements the
IEnumerable interface. This week I realized it should implement
IEnumerable<T>.
But when I changed the return type of the GetEnumerator method the compiler
said the class no longer implemented IEnumerable.
IEnumerable<Thas IEnumerable as a base interface, so I had assumed that
implementing IEnumerable<Twould satisfy IEnumerable as well. After some
time wrestling with this I finally tried implementing both interfaces
explicitly even though both do the same exact thing:
IEnumerator<TIEnumerable<T>.GetEnumerator ...
IEnumerator IEnumerable.GetEnumerator ...
Much to my surprise, it works.
While I realize that inheritance and IS_A don't apply to interfaces, this
seems counter-intuitive; shouldn't a method that returns IEnumerable<T>
satisfy IEnumerable?