Does C# allow double semicolon ; ; if so, are there any special ways?

后端 未结 7 1706
盖世英雄少女心
盖世英雄少女心 2020-11-29 12:18

I am writing a statement and it compiles, but the compiler [VS] never tells me that I put the semicolon two times.

This means in ASP.NET MVC 3

return         


        
7条回答
  •  不知归路
    2020-11-29 12:39

    At the moment no specific reason to write a double semicolon comes to my mind. As far as I know Visual Studio only complains about semicolons that can lead to a unwanted behavior, like the following snippet:

    if (true)
        ;
    

    As the semicolon is an empty instruction, the whole if-clause is rendered useless. The Visual Studio complains about all such constructs (using, for, foreach, and so on) without brackets around them.

    So the following code is fine for the VS:

     if (true)
     {
          ;
     }
    

提交回复
热议问题