C Sharp Programming/Keywords/else

The keyword identifies a  clause of an  statement with the following syntax:


 * if-statement ::= "" "" condition "" if-body "" else-body
 * condition ::= boolean-expression
 * if-body ::= statement-or-statement-block
 * else-body ::= statement-or-statement-block

An clause immediately follows an if-body. It provides code to execute when the condition is false. Making the else-body another statement creates the common cascade of, , , ,  statements:

The above example only checks whether is less than 0, if  is not 4. It in turn only checks whether is 0, if  is not less than 0. Since none of the conditions are true, it executes the body of the final clause.

/Keywords