Queue[,] inventqueue = new Queue[10,7];
for(int row = 0; row < inventqueue.GetLength(0); row++)
{
for (int col = ; col < inventqueue.GetLength(1); col++)
{
if(inventqueue[row,col].Count != 0)
{
MessageBox.Show("Theres a queue on " + row + "," + col);
}
}
}
我一直在尝试这个,但是visual studio给了我错误“对象引用未设置为对象的实例。”
答案 0 :(得分:0)
您只分配双数组,您仍然需要为数组中的每个条目分配队列,如:
Queue[,] inventqueue = new Queue[10,7];
for(int row = 0; row < inventqueue.GetLength(0); row++)
{
for (int col = ; col < inventqueue.GetLength(1); col++)
{
inventqueue[row,col] = new Queue();
}
}