C# Empty Statement

后端 未结 13 2262
情深已故
情深已故 2020-11-29 12:34

The C# language specification defines the empty-statement grammar production, which allows me to do something like this:

static void Main(string[] a         


        
13条回答
  •  北海茫月
    2020-11-29 12:54

    It allows have blocks of code IFDEF'd out, and the surrounding code still build. eg

    if(true){
    #if(DEBUG)
    System.Console.WriteLine("Debug comment");
    #endif
    }
    

    which could be written as an empty block, if you dislike brackets:

    if(true)
    #if(DEBUG)
       System.Console.WriteLine("Debug comment")
    #endif
    ;
    

提交回复
热议问题