【发布时间】:2013-02-19 05:09:02
【问题描述】:
偶然在MSDN上看了一下IList<T>和ICollection<T>,看到这两个接口的定义是:
public interface ICollection<T> : IEnumerable<T>, IEnumerable
public interface IList<T> : ICollection<T>, IEnumerable<T>, IEnumerable
注意ICollection<T> 继承自IEnumerable<T> 和IEnumerable,没关系。 IList<T>继承自ICollection<T>,但是为什么IList<T>又要继承IEnumerable<T>和IEnumerable呢?
这有什么理由吗?
【问题讨论】:
-
我相信这是为了兼容性,因为 IEnumerable
带有 2.0 版
标签: c# .net generics ienumerable