1

Duplicate:

Why IEnumerable<T> inherits from IEnumerable?


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

Community
  • 1
  • 1
Joan Venge
  • 315,713
  • 212
  • 479
  • 689

1 Answers1

4

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
  • 380,855
  • 102
  • 628
  • 825
  • Thanks. By branches I meant, they are like List vs List, are independent of each other. – Joan Venge Jul 23 '09 at 21:42
  • 1
    But couldn't they update those old methods to also work with the generic version? – Joan Venge Jul 23 '09 at 21:43
  • This way old assemblies expecting IEnumerable will work with the IEnumerable 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 Jul 23 '09 at 22:04
  • Nor might it be worth the time to fix already working code like that. – Lasse V. Karlsen Jul 23 '09 at 22:07