日期:2014-05-17  浏览次数:20940 次

C#ArryList()在两个类中怎么调用
我在claa A 中定义一个集合
class A
{
     ArryList list=new ArryList();

      //z在list中加一些数据
}
class B 
{
      //怎样在这个类中得到A中的list
}

------解决方案--------------------
在 class A内可以public static ArrayList al = new ArrayList();
然后在class B中 直接 A.al获取(ArrayList al = A.al;);如果class A中不设置成静态的(static)那就要通过实例化一个Class A来获取(A ca = new A(); ArrayList al = ca.al);