【发布时间】:2011-07-23 10:17:32
【问题描述】:
查看下面的函数测试代码:
List<Square> tempArr = new List<Square>();
Coin tempCoin = new Coin(eCoinType.White);
Square tempMove = new Square(1, eColumn.A, tempCoin);
tempArr.Add(tempMove);
m_OtheloGame.isLegalMove(tempMove, ref tempArr);
编译器在最后一行用 NullExceptionError 绘制“tempArr”。
我不明白为什么,因为我已经在第一行分配了 tempArr,所以它不能为空。
【问题讨论】:
-
你能解释一下“编译器绘制 tempArr”是什么意思吗?
-
是的,我的意思是它带有红色下划线
-
当你尝试编译它时输出是什么?
-
您可以发布异常的详细信息吗?调用堆栈中的内容可能比我们在问题中看到的要多。
-
你真的需要通过引用传递
tempArr吗?
标签: c# nullreferenceexception compiler-errors