Is there a way to fall through multiple case statements without stating case value:
repeatedly?
(有没有一种方法可以遍历多个case语句而不声明case value:
重复?)
I know this works:
(我知道这可行:)
switch (value)
{
case 1:
case 2:
case 3:
//do some stuff
break;
case 4:
case 5:
case 6:
//do some different stuff
break;
default:
//default stuff
break;
}
but I'd like to do something like this:
(但我想做这样的事情:)
switch (value)
{
case 1,2,3:
//Do Something
break;
case 4,5,6:
//Do Something
break;
default:
//Do the Default
break;
}
Is this syntax I'm thinking of from a different language, or am I missing something?
(我是从其他语言考虑使用这种语法吗?还是我错过了某些内容?)
ask by theo translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…