zoukankan      html  css  js  c++  java
  • 常用接口简析3---IList和List的解析

     常用接口的解析(链接)

          1.IEnumerable深入解析
          2.IEnumerable、IEnumerator接口解析
          3.IComparable、IComparable接口解析

        学习第一步,先上菜:

     1 #region 程序集 mscorlib.dll, v4.0.30319
     2 // C:Program FilesReference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientmscorlib.dll
     3 #endregion
     4 
     5 using System;
     6 using System.Collections;
     7 using System.Reflection;
     8 using System.Runtime.CompilerServices;
     9 
    10 namespace System.Collections.Generic
    11 {
    12     // 摘要:
    13     //     表示可按照索引单独访问的一组对象。
    14     //
    15     // 类型参数:
    16     //   T:
    17     //     列表中元素的类型。
    18     [TypeDependency("System.SZArrayHelper")]
    19     public interface IList<T> : ICollection<T>, IEnumerable<T>, IEnumerable
    20     {
    21         // 摘要:
    22         //     获取或设置指定索引处的元素。
    23         //
    24         // 参数:
    25         //   index:
    26         //     要获得或设置的元素从零开始的索引。
    27         //
    28         // 返回结果:
    29         //     指定索引处的元素。
    30         //
    31         // 异常:
    32         //   System.ArgumentOutOfRangeException:
    33         //     index 不是 System.Collections.Generic.IList<T> 中的有效索引。
    34         //
    35         //   System.NotSupportedException:
    36         //     设置该属性,而且 System.Collections.Generic.IList<T> 为只读。
    37         T this[int index] { get; set; }
    38 
    39         // 摘要:
    40         //     确定 System.Collections.Generic.IList<T> 中特定项的索引。
    41         //
    42         // 参数:
    43         //   item:
    44         //     要在 System.Collections.Generic.IList<T> 中定位的对象。
    45         //
    46         // 返回结果:
    47         //     如果在列表中找到,则为 item 的索引;否则为 -1。
    48         int IndexOf(T item);
    49         //
    50         // 摘要:
    51         //     将一个项插入指定索引处的 System.Collections.Generic.IList<T>。
    52         //
    53         // 参数:
    54         //   index:
    55         //     从零开始的索引,应在该位置插入 item。
    56         //
    57         //   item:
    58         //     要插入到 System.Collections.Generic.IList<T> 中的对象。
    59         //
    60         // 异常:
    61         //   System.ArgumentOutOfRangeException:
    62         //     index 不是 System.Collections.Generic.IList<T> 中的有效索引。
    63         //
    64         //   System.NotSupportedException:
    65         //     System.Collections.Generic.IList<T> 为只读。
    66         void Insert(int index, T item);
    67         //
    68         // 摘要:
    69         //     移除指定索引处的 System.Collections.Generic.IList<T> 项。
    70         //
    71         // 参数:
    72         //   index:
    73         //     从零开始的索引(属于要移除的项)。
    74         //
    75         // 异常:
    76         //   System.ArgumentOutOfRangeException:
    77         //     index 不是 System.Collections.Generic.IList<T> 中的有效索引。
    78         //
    79         //   System.NotSupportedException:
    80         //     System.Collections.Generic.IList<T> 为只读。
    81         void RemoveAt(int index);
    82     }
    83 }

          List的内容太多了

    1 public class List<T> : IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable

           从上面内容就可以看到,List继承了三个泛型接口,还继承了三个常规的接口。

           说白了,就是List是类,继承IList<T>泛型版本和IList非泛型版本接口。List是一个集合类。

           IList<T>是接口,说明这个对象要去实现接口里定义的方法。

           IList<T> 服务泛型集合(List<T>),IList服务非泛型集合(Array)

        以上只是个人学习的理解,后续会进行跟进,大家有什么想法可以畅所欲言。

           

  • 相关阅读:
    firefox和ie下面的初始化checkbox
    全球宽带排名出炉 韩国第一中国未入榜(附表)
    逆向查询所有父栏目
    js的点点滴滴
    Treeview绑定数据源 层叠结构数据源的应用
    asp.net读取服务器端文件夹列表
    Treeview绑定数据源 层叠结构数据源的应用(续--完善篇)
    VC数据类型
    jQuery核心文档(翻译中)
    iscroll 下拉刷新,上拉加载
  • 原文地址:https://www.cnblogs.com/xiaowangzi1987/p/6746108.html
Copyright © 2011-2022 走看看