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);
}
}
}
I have been trying this out but visual studio is giving me the error "Object reference not set to an instance of an object."
解决方案
You're allocating only the double array, you still need to allocate Queues for each entry in the array like:
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();
}
}