【发布时间】:2014-01-05 04:16:05
【问题描述】:
我有一个数组
也就是说,每个项目在以下索引中都有其类别。 我需要类别为 TotalNumbers 和 CurrentNumbers 的所有项目。
我试过了
int i = 1;
foreach (string item in statsname)
{
//only number type stats are added to the comboboxes.
if ((statsname[i].ToUpperInvariant()==("TOTALNUMBER")) || ((statsname[i].ToUpperInvariant()==("CURRENTNUMBER"))))
{
comboBox1.Items.Add(statsname[i-1]);
i++;
i++;
}
comboBox1.SelectedIndex = 0;
}
显然这并不能正确检查我需要的内容。
我需要如何修改我的代码以获得我需要的东西?
【问题讨论】: