2

I have taken a look on IList<T> and ICollection<T> on MSDN by chance, and see that the definition of these two interfaces are:

public interface ICollection<T> : IEnumerable<T>, IEnumerable
public interface IList<T> : ICollection<T>, IEnumerable<T>, IEnumerable

Notice that ICollection<T> inherits from IEnumerable<T> and IEnumerable, that's okay. IList<T> inherits from ICollection<T>, but why IList<T> has to inherit IEnumerable<T> and IEnumerable again?

Any there any reason for this?

cuongle
  • 74,024
  • 28
  • 151
  • 206

1 Answers1

5

The documentation is generated that way so you can see what interfaces a type implements without having to follow transitive links through the interface inheritance hierarchy.

Sam Harwell
  • 97,721
  • 20
  • 209
  • 280
  • I agree. There's no structural reason, except for clarity IMHO. – John Willemse Feb 19 '13 at 05:18
  • It is just the documentation. If you check the mscorlib library, for example with dotPeek then you can see, that in the IList interface the interfaces are listed again like this: – Márk Gergely Dolinka Feb 19 '13 at 05:26
  • Not really if you try to implement `ILIst` you would indeed get and need two versions of the `GetEnumerator` – V4Vendetta Feb 19 '13 at 05:27
  • @V4Vendetta I believe you misunderstood the question – Sam Harwell Feb 19 '13 at 05:31
  • 1
    @280Z28 I guess you are right, maybe you can refer this in the answer http://reflector.webtropy.com/default.aspx/4@0/4@0/untmp/DEVDIV_TFS/Dev10/Releases/RTMRel/ndp/clr/src/BCL/System/Collections/Generic/IList@cs/1305376/IList@cs – V4Vendetta Feb 19 '13 at 05:36