C# Empty Statement

后端 未结 13 2344
情深已故
情深已故 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:40

    Here are two uses:

    while(DoSomething()) ;
    

    and

    void M() {
        if(someCondition) goto exit;
        // ...
        exit: ;
    }
    

    There are many others. It's a useful device anytime there is nothing to do but a statement is required.

提交回复
热议问题