日期:2014-05-18  浏览次数:20502 次

这是怎么回事
C# code

List<Dept>[] GetDeptList = null;
List<Dept> aaa = new PublicLibraryBLL().GetContainDept(CInfo);
GetDeptList[0] = aaa;



运行提示
System.NullReferenceException: 未将对象引用设置到对象的实例。
行 55: GetDeptList[0] = aaa;

有空帮忙指点一下,
须要什么我提供

------解决方案--------------------
List<Dept>[] GetDeptList = null;只是声明了GetDeptList ,没有添加任何数据,你访问[0]索引当然不存在了

------解决方案--------------------
想赋值,也要先添加啊,GetDeptList.Add
------解决方案--------------------
虽然不是很明白你为什么这样写?
数组是要在new 时定义长度的
C# code

string[] aaa=new string[]{"1","2","3"};//3个
GetDeptList =new List<Dept>[] {aaa}

------解决方案--------------------
探讨

List<Dept>[] GetDeptList = null;只是声明了GetDeptList ,没有添加任何数据,你访问[0]索引当然不存在了

------解决方案--------------------
楼主仔细检查一下呀
------解决方案--------------------
参数为空或者没设置
------解决方案--------------------
PublicLibraryBLL().GetContainDept(CInfo);这个得到的类型是什么?