本文介绍了开关,外壳,以及它有时如何让你跌倒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我很困惑如何在开关中限制穿透。例如
以下作品:
string switch_test =" a" ;;
开关(switch_test)
{
case" a":
case" b":
case" c":
doSomething(a);
休息;
}
但以下不起作用:
string switch_test =" a" ;;
switch(switch_test)
{
case" a":
if(< some test>)
break;
case" b":
case" c":
doSomething(a);
}
为什么会这样?
I''m confused as to how fallthrough is limited in switch. For example
the following works:
string switch_test = "a";
switch (switch_test)
{
case "a":
case "b":
case "c":
doSomething(a);
break;
}
but the following does not work:
string switch_test = "a";
switch (switch_test)
{
case "a":
if (<some test>)
break;
case "b":
case "c":
doSomething(a);
}
why is that?
推荐答案
这篇关于开关,外壳,以及它有时如何让你跌倒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!