2012-01-28 30 views
0
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是給我的錯誤「不設置到對象的實例對象引用。」是否有可能在隊列使用二維數組? windows窗體

回答

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(); 
    } 
} 
+0

感謝,效果不錯! :) – 2012-01-28 08:58:54

相關問題