13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 15 Statementsif (x) {if (y) {F();}else {G();}}end example]An if statement is executed as follows:• The boolean-expression (§14.16) is evaluated.• If the boolean expression yields true, control is transferred to the first embedded statement. When andif control reaches the end point of that statement, control is transferred to the end point of the ifstatement.• If the boolean expression yields false and if an else part is present, control is transferred to thesecond embedded statement. When and if control reaches the end point of that statement, control istransferred to the end point of the if statement.• If the boolean expression yields false and if an else part is not present, control is transferred to theend point of the if statement.The first embedded statement of an if statement is reachable if the if statement is reachable and theboolean expression does not have the constant value false.The second embedded statement of an if statement, if present, is reachable if the if statement is reachableand the boolean expression does not have the constant value true.The end point of an if statement is reachable if the end point of at least one of its embedded statements isreachable. In addition, the end point of an if statement with no else part is reachable if the if statement isreachable and the boolean expression does not have the constant value true.15.7.2 The switch statementThe switch statement selects for execution a statement list having an associated switch label that correspondsto the value of the switch expression.switch-statement:switch ( expression ) switch-blockswitch-block:{ switch-sections opt }switch-sections:switch-sectionswitch-sections switch-sectionswitch-section:switch-labels statement-listswitch-labels:switch-labelswitch-labels switch-labelswitch-label:case constant-expression :default :A switch-statement consists of the keyword switch, followed by a parenthesized expression (called theswitch expression), followed by a switch-block. The switch-block consists of zero or more switch-sections,183

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!