Control cannot fall through from one case label

前端 未结 8 1252
旧巷少年郎
旧巷少年郎 2020-11-27 05:50

I am trying to write a switch statement that would type the search term in the search field depending on whichever search textbox is present. I have the following code. But

8条回答
  •  清酒与你
    2020-11-27 06:19

    You can do more than just fall through in C#, but you must utilize the "dreaded" goto statement. For example:

    switch (whatever)
    {
      case 2:
        Result.Write( "Subscribe" );
        break;
      case 1:
        Result.Write( "Un" );
        goto case 2;
    }
    

提交回复
热议问题