代码错误开关盒" ? [英] error in code " switch case" ?
本文介绍了代码错误开关盒" ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
为什么此代码只运行第一部分?
c#.
hello,
Why this code is run only the first part?
c#.
int i = 1;
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
int s = Int32.Parse(textBox3.Text); //textbox1=1
switch (s )
{
case 1:
{
s += i ;
MessageBox .Show ("1");
webBrowser1.Navigate("www.google.com");
break;
}
case 2: //no run?
{
s += i;
MessageBox .Show ("2");
webBrowser1.Navigate("www.bing.com");
break;
}
}
}
推荐答案
也许您是否使用了正确的文本框?
Perhaps if you used the right textbox?
int s = Int32.Parse(textBox3.Text); //textbox1=1
请注意此处的数字...
这就是我永远对初学者说的原因:切勿对对象名称使用VS默认值.这会引起混乱-使用描述用户将如何处理事情的名称! tbSelectSearchEngine
很难混淆...
Note the numbers there...
This is why I am forever saying to beginners: Never use the VS defaults for object names. It leads to confusion - use names which describe what the user will do with things! tbSelectSearchEngine
is a lot harder to confuse...
这篇关于代码错误开关盒" ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文