zoukankan      html  css  js  c++  java
  • IEnumerable<> ICollection <> IList<> 区别

    IEnumerable< ICollection < IList区别

        public interface IEnumerable
        {
            IEnumerator GetEnumerator();
        }

    再看ICollection<T> 

        public interface ICollection<T> : IEnumerable<T>, IEnumerable
        {
            void Add(T item);
            void Clear();
            bool Contains(T item);
            void CopyTo(T[] array, int arrayIndex);
            bool Remove(T item);
            int Count {  get; }
            bool IsReadOnly { get; }
        }
    再看IList<T>
        public interface IList<T> : ICollection<T>, IEnumerable<T>, IEnumerable
        {
            int IndexOf(T item);
            void Insert(int index, T item);
            void RemoveAt(int index);
            T this[int index] {get;set; }
        }

    可见,IList要比ICollection要多索引器的功能,另外还可以用索引器来进行修改,标识IList是可读写的链表,而ICollection是只读的链表;

  • 相关阅读:
    【游戏开发】Excel表格批量转换成CSV的小工具
    iOS
    iOS
    Xcode
    iOS
    iOS
    iOS
    iOS
    iOS
    iOS
  • 原文地址:https://www.cnblogs.com/luyujie/p/3443562.html
Copyright © 2011-2022 走看看