Why IList<T> inherits IEnumerable<T> and IEnumerable again

点点圈 提交于 2019-12-20 04:13:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!