为什么文字不会改变第二次 [英] why text not changing second time
本文介绍了为什么文字不会改变第二次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
if (button1.Text == button1)
{
button1.Text = BUTTON2跨度>;
}
如果(button1.Text == button2)
{
button1.Text = 按钮1\" 跨度>;
}
为什么不工作
解决方案
您可能希望逐行浏览代码并考虑您的逻辑。您可能还想查看两个if语句并查看您将按钮的文本设置为是什么。
BTW:您只需要一个if语句,不是2.
[不是答案,应该删除。此外,这篇文章没有任何意义-SA]
而不是如果条件我只需要使用if else
< blockquote class =FQ>Quote:if(button1.Text ==button1)
{
button1 .Text =button2;
}
if(button1.Text ==button2)
{
button1.Text =button2; //< - 错误的行
}
以粗体显示的错误行,将其更改为
button1.Text =button1;
if (button1.Text == "button1")
{
button1.Text = "button2";
}
if (button1.Text == "button2")
{
button1.Text = "button1";
}
why its not working
解决方案
You might want to step through the code line-by-line and think about your logic. You might also want to look at both if statements and see what you''re setting the Text of the button to.
BTW: You only need ONE if statement, not 2.
[Not an answer, should be removed. Besides, this post makes no sense —SA]
instead of to if conditions i just needed to use if else
Quote:if (button1.Text == "button1")
{
button1.Text = "button2";
}
if (button1.Text == "button2")
{
button1.Text = "button2"; // <-- wrong line
}
Wrong line in bold, change it to
button1.Text = "button1";
这篇关于为什么文字不会改变第二次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文