views:

259

answers:

1

Duplicate:

Why IEnumerable<T> inherits from IEnumerable?


It looks like IEnumerable, ICollection, IList and their generic equivalents are in separate branches.

+4  A: 

It does this so that all older methods and code that knows how to handle an IEnumerable is guaranteed to work with your collections.

Implementing IEnumerable<T> implicitly means you implement IEnumerable.

By branches, do you mean namespaces?

Lasse V. Karlsen
Thanks. By branches I meant, they are like List vs List<T>, are independent of each other.
Joan Venge
But couldn't they update those old methods to also work with the generic version?
Joan Venge
This way old assemblies expecting IEnumerable will work with the IEnumerable<T> class. Sometimes there isn't source code to modify (ie., the new class is part of something that plugs into an existing app at runtime, someone using a library that provides only assemblies, no source).
Michael Burr
Nor might it be worth the time to fix already working code like that.
Lasse V. Karlsen