Is there a way to make my switch/case fall through to the next case in C#?

后端 未结 4 1746
后悔当初
后悔当初 2021-02-19 03:28

I\'m using a switch/case statement to handle some updates for a deployed application. Basically, I want to waterfall through the cases to perform the update from the current run

4条回答
  •  -上瘾入骨i
    2021-02-19 04:00

    You need to add a break statement even if it's the last case:

    switch (myCurrentVersion)
    {
        case null:
        case "":
        case "0":
            UpdateToV1();
            goto case "1";
        case "1":
            UpdateToV2();
            break;
    }
    

提交回复
热议问题