c#中的“计算”按钮不起作用 private void textBox1\u按键(对象发送器,按键事件参数e) { 如果(e.KeyChar==(char)13) { 如果(textBox1.Text!=“”) { listBox1.Items.Add(textBox1.Text); textBox1.Text=“”; } } } 私有无效按钮1\u单击(对象发送者,事件参数e) { inti,n; 双x,m; n=列表框1.Items.Count; m=0; 对于(i=0;i
非常感谢您帮助我放置JUSI++并且现在看起来它正在工作。]c#中的“计算”按钮不起作用 private void textBox1\u按键(对象发送器,按键事件参数e) { 如果(e.KeyChar==(char)13) { 如果(textBox1.Text!=“”) { listBox1.Items.Add(textBox1.Text); textBox1.Text=“”; } } } 私有无效按钮1\u单击(对象发送者,事件参数e) { inti,n; 双x,m; n=列表框1.Items.Count; m=0; 对于(i=0;i,c#,C#,非常感谢您帮助我放置JUSI++并且现在看起来它正在工作。] private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)13) { if(textBox1.Text !="") { listBox1.Items.Add(textBox1.Text);
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
if(textBox1.Text !="")
{
listBox1.Items.Add(textBox1.Text);
textBox1.Text="";
}
}
}
private void button1_Click(object sender, EventArgs e)
{
int i, n;
double x, m;
n = listBox1.Items.Count;
m = 0;
for (i=0;i<n;i=i++)
{
x=Convert.ToInt32(listBox1.Items[i]);
m = m + 1;
}
textBox2.Text=Convert.ToString(m);
}
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.RemoveAt(listBox1.SelectedIndex);
}
}
}
private void textBox1\u按键(对象发送器,按键事件参数e)
{
如果(e.KeyChar==(char)13)
{
如果(textBox1.Text!=“”)
{
listBox1.Items.Add(textBox1.Text);
textBox1.Text=“”;
}
}
}
私有无效按钮1\u单击(对象发送者,事件参数e)
{
inti,n;
双x,m;
n=列表框1.Items.Count;
m=0;
对于(i=0;i为什么你将x
声明为一个double,然后用Int32
初始化它?你首先用x
做什么?谁教你写i=i++
?你的循环增量i=i++
看起来很可疑:你可能会在C优先规则中侥幸逃脱(我不记得了)但你真的只需要i=i+1
或i++
(甚至++i
)@Rup它在C#中有很好的定义。但是++
的副作用发生在=
的副作用之前,所以它最终存储了它已经拥有的相同的值。@hvd谢谢:我知道它有很好的定义,但不完全是如何定义的。在我看来,一般来说,如果有些东西看起来令人困惑,它不应该这样写。
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
if(textBox1.Text !="")
{
listBox1.Items.Add(textBox1.Text);
textBox1.Text="";
}
}
}
private void button1_Click(object sender, EventArgs e)
{
int i, n;
double x, m;
n = listBox1.Items.Count;
m = 0;
for (i=0;i<n;i++)
{
x=Convert.ToDouble(listBox1.Items[i]);
m = m + x;
}
textBox2.Text=Convert.ToString(m);
}
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.RemoveAt(listBox1.SelectedIndex);
}
}
}