试图在列表框中显示我的数组列表?

时间:2014-04-01 04:38:01

标签: c# arrays listbox

//to display my inventory array
for (int i = 0; i < arrayInventory[18]);
{
  lsbInvetory.Items.Add(arrayInventory[18]);
}

此代码未显示错误,但不会显示在列表框中。

以下是数组列表框的代码

  double[] arrayInventory = new double[]  // declaring & initialized single array
  {200, 50, 30, 25, 10, 10, 20, 14, 14, 10, 20, 15, 12, 20, 60, 25, 10, 10 };

1 个答案:

答案 0 :(得分:0)

像这样改变

for (int i = 0; i < arrayInventory.Length; i++) 
{
    lsbInvetory.Items.Add(arrayInventory[i]);
}