Do else if statements exist in C#?

前端 未结 8 1568
感动是毒
感动是毒 2021-02-01 12:51

I have come across the following code in C#.

if(condition0) statement0;
else if(condition1) statement1;
else if(condition2) statement2;
else if(condition3) state         


        
8条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-01 13:33

    The Selection Statement of the C# Language Specification only shows if and switch statements. If you select the if statement, it says:

    The if statement selects a statement for execution based on the value of a Boolean expression.

    if-statement:

    if ( boolean-expression ) embedded-statement

    if ( boolean-expression ) embedded-statement else embedded-statement boolean-expression: expression

    An else part is associated with the lexically nearest preceding if that is allowed by the syntax

提交回复
热议问题