首先我看看 IEnumerable:性能
// 摘要: // 公開枚舉器,該枚舉器支持在指定類型的集合上進行簡單迭代。 // // 類型參數: // T: // 要枚舉的對象的類型。 [TypeDependency("System.SZArrayHelper")] public interface IEnumerable<out T> : IEnumerable { // 摘要: // 返回一個循環訪問集合的枚舉器。 // // 返回結果: // 可用於循環訪問集合的 System.Collections.Generic.IEnumerator<T>。 IEnumerator<T> GetEnumerator(); }
IEnumerable<T> 實現IEnumerable接口方法,那IEnumberable作什麼的,其實就提升能夠循環訪問的集合。說白了就是一個迭代。code
再來看看ICollection:對象
// 摘要: // 定義操做泛型集合的方法。 // // 類型參數: // T: // 集合中元素的類型。 [TypeDependency("System.SZArrayHelper")] public interface ICollection<T> : IEnumerable<T>, IEnumerable
原來ICollection<T> 同時繼承IEnumerable<T>和IEnumerable兩個接口,按個人理解就是,ICollection繼續它們2個接口並且擴展了方法,功能強多了。
由原來的步槍變成半自動步槍blog
咱們繼續看IList:排序
public
interface
IList<T> : ICollection<T>, IEnumerable<T>, IEnumerable
繼承
靠 IList 繼承它們三個接口,怪不得功能這麼多啊,那應該屬於全自動步槍了接口
最後來看看List:get
public class List<T> : IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable
這個時候你們仔細看看,它們都是接口,只有List 是類,不只實現它們的接口,並且還擴展了太多的方法給我利用。哇靠,幾乎全部功能都能實現了,簡直是激光步槍io
按照功能排序:List<T> 《IList<T> 《ICollection<T>《IEnumerable<T>class
按照性能排序:IEnumerable<T>《ICollection<T>《IList<T>《List<T>