问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/14950240/why-ilistt-inherits-ienumerablet-and-ienumerable-again