【发布时间】:2016-08-31 10:37:29
【问题描述】:
当我想将项目添加到锯齿状数组中的元素时,我得到 NullReferenceException。
public List<int>[][] Map;
void Start()
{
Map = new List<int>[60][];
for(byte x = 0; x < 60 ; x++)
{
Map[x] = new List<int>[60];
// initialization of rows
}
Map [23] [34].Add (21);
}
【问题讨论】:
-
在您开始向列表添加项目之前,您需要实例化您的列表。 IE。
Map[23][34] = new List<Int>()
标签: c# .net list jagged-arrays