Switch statement with multiple constant-expression in c#. Is it possible?
本问题已经有最佳答案,请猛点这里访问。
Possible Duplicate:
Multiple Cases in Switch:
是否可以执行如下的多常量表达式switch语句
1 2 3 4 5 6 7 8 9 10 11 | switch (i) { case"run","notrun","runfaster": //Something like this. DoRun(); break; case"save": DoSave(); break; default: InvalidCommand(command); break; } |
是的,是的。可以对同一节使用多个大小写标签:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | switch (i) { case"run": case"notrun": case"runfaster": DoRun(); break; case"save": DoSave(); break; default: InvalidCommand(command); break; } |