I don't understand why IList
implements IEnumerable
taking in consideration that IList
implements ICollection
that implements IEnumerable
also.
I assume you want to know why it declares that it implements ICollection
as well as IEnumerable
, when the first implies the second. I suspect the main reason is clarity: it means people don't need to look back to ICollection
to check that that already extends IEnumerable
.
There are other times when you need to redeclare an interface implementation, if you want to re-implement an interface method which was previously explicitly implemented in a base class - but I don't think that's the reason in this case.
EDIT: I've been assuming that the source code that the docs are built from has the declaration including both interfaces. Another possible alternative is that all interfaces in the hierarchy are automatically pulled in by the doc generator. In which case the question becomes "why does the doc generator do that" - and the answer is almost certainly still "clarity".
IList
only implements IEnumerable
by associaton; i.e. it implements IEnumerable
precisely because it inherits ICollection
which is IEnumerable
. You'd get the same with type hierarchies (although only single inheritance:
class Enumerable {}
class Collection : Enumerable {}
class List : Collection {}
so List
is an Enumerable
; in the same way, IList
is IEnumerable
.
For example, if I write:
interface IA {}
interface IB : IA { }
interface IC : IB { }
And look at the metadata, then it appears that IC : IA, IB
- but this is only indirect; here's the IL:
.class private interface abstract auto ansi IA
{
}
.class private interface abstract auto ansi IB
implements IA
{
}
.class private interface abstract auto ansi IC
implements IB, IA
{
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With