如何声明其他if语句 [英] how to BREAK else if statement

查看:144
本文介绍了如何声明其他if语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在单击事件中有两个声明



  if ()
{
}
else if ()
{
messagebox.show( hai);
}
else
{
}


if ()
{
}
else
{
}





如果第一个语句中的消息框被执行,第二个语句不应该执行,否则两个都需要执行..如何做到这一点。 ..,帮帮我:,

解决方案

请看我对这个问题的评论,并按字面意思完成你最后一句中所写的内容。



-SA


如果显示消息框时只有 不需要第二个if()语句然后按照罗伯特的建议 - 例如:

  bool  doSecond =  true ; 
if ()
{
// 执行某些操作,如果应该触发第二个
}
else if ()
{
messagebox.show( hai);
doSecond = false ;
}
其他
{
// < span class =code-comment>做一些事情,第二个如果应该开火

}


如果(doSecond&& ifCondition)
{
// 不要这样做仅当显示消息框
}
否则
{
}


i am having two statement in single click event

if()
{
}
else if()
{
messagebox.show("hai");
}
else
{
}


if()
{
}
else
{
}



if that messagebox in first statement executed, second statement should not execute otherwise both need to execute.. how to do that..., help me out :,

解决方案

Please see my comment to the question, and do exactly what is written in your last clause literally.

—SA


If it''s only when the message box is shown that the 2nd if() statement is not required then go with Robert''s suggestion - for example:

bool doSecond = true;
if()
{
    //do something and 2nd if should fire
}
else if()
{
    messagebox.show("hai");
    doSecond = false;
}
else
{
    //do something and 2nd if should fire
}


if(doSecond && ifCondition )
{
    //don't do this only when message box shown
}
else
{
}


这篇关于如何声明其他if语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆