如何使用数组的数值而不是用于确定大小写的数组中的数字?在我的代码:如何将数组值用于大小写切换(不是数组编号)
for (int x = 0; x < 3; x++)
{
switch (position[x])
{
case 0:
label1.Text = people[x];
break;
case 1:
label2.Text = people[x];
break;
case 2:
label3.Text = people[x];
break;
}
}
当该运行时,它使用x在位置[],而不是定位[X]的值,用于确定要使用的情况下。例如,当x是0,但位置[x]的值是1时,它使用情况0.如何获取值?
编辑:我的代码确实是问题....出于某种原因,调试一大早具有创建虚假的图像效果...:P作为一个供参考,在这里是正确的代码...
for (int x = 0; x < 3; x++)
{
if (position[x] == 2)
{
position[x] = 0;
}
else
position[x]++;
}
for (int x = 0; x < 3; x++)
{
int val = position[x];
switch (val)
{
case 0:
label1.Text = people[x];
break;
case 1:
label2.Text = people[x];
break;
case 2:
label3.Text = people[x];
break;
}
在位置[x]的上面第一次出现时,我改为只放置了x。感谢所有的帮助!
什么是 '位置',然后的目的是什么? – ata 2010-01-27 14:09:37
你的代码看起来很好,你确定这是问题吗? – 2010-01-27 14:09:53
我没有看到这段代码有什么问题。你确定位置[]中的值是否如你所期望的那样? – Aaron 2010-01-27 14:10:46