ArrayList 继承自Ilist,IList 是 ICollection 接口的子代
Ilist和ICollections 都说是:是所有非泛型列表的基接口(msdn)但有一个例子:(MSDN)
System.Collections.ArrayList list = new System.Collections.ArrayList();
// Add an integer to the list.
list.Add(3);
// Add a string to the list. This will compile, but may cause an error later.
list.Add("It is raining in Redmond.");int t = 0;
// This causes an InvalidCastException to be returned.
foreach (int x in list)
{
    t += x;
}
小弟不明白ArrayList是不是泛型的?请赐教!

解决方案 »

  1.   

    IList是个接口,是实现,而不是继承
    只有接口才能继承接口
      

  2.   

    ArrayList里面放的是Object,出入要类型转换
      

  3.   

    ArrayList内的成员类型是objct,C#中所有的数据类型都派生自objct当然可以这样用。
      

  4.   

    上面是举的例子比较,应该是这样:
    ArrayList<int> list=new ArrayList<int>
      

  5.   

    // The .NET Framework 2.0 way to create a list
    List<int> list1 = new List<int>();// No boxing, no casting:
    list1.Add(3);// Compile-time error:
    // list1.Add("It is raining in Redmond.");
    这是MSDN上的源代码
      

  6.   

    ArrayList内的成员类型是objct,C#中所有的数据类型都派生自objct当然可以这样用。谢谢老兄 学习了.
      

  7.   

    ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_csref/html/80f037cd-9ea7-48be-bfc1-219bfb2d4277.htm
    我的总题出自这(MSDN2005)
    我就是想知道Arraylist是不是可以声明成泛型,如果可以为什么有这句:IList是所有非泛型列表的基接口(msdn)
    谢谢.
      

  8.   

    ArrayList不是泛型
    System.Collections.Generic.List<>才是