在切换的情况下你能有多个陈述吗?

时间:2014-08-31 11:34:51

标签: c# switch-statement case

switch (other.gameObject.tag) {
            case "Electron":
                    elec = true;
                    pyst = other;
                    break;
            case "Proton":
                    prot = true;
                    pyst = other;
                    break;
            }

看起来很简单,但找不到答案。代码在c#中,所以pyst = other;线路实施以及elec = true;?

1 个答案:

答案 0 :(得分:0)

当代码进入案例块时,它将继续执行所有命令,直到它到达break或说return语句。

在其他一些语言中,如果省略休息,它将继续执行其余的命令(这会导致“控件不能从一个案例标签中掉落”C#中的错误)

相关问题