13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 15 Statementswhile-statement:while ( boolean-expression ) embedded-statementA while statement is executed as follows:• The boolean-expression (§14.16) is evaluated.• If the boolean expression yields true, control is transferred to the embedded statement. When and ifcontrol reaches the end point of the embedded statement (possibly from execution of a continuestatement), control is transferred to the beginning of the while statement.• If the boolean expression yields false, control is transferred to the end point of the while statement.Within the embedded statement of a while statement, a break statement (§15.9.1) may be used to transfercontrol to the end point of the while statement (thus ending iteration of the embedded statement), and acontinue statement (§15.9.2) may be used to transfer control to the end point of the embedded statement(thus performing another iteration of the while statement).The embedded statement of a while statement is reachable if the while statement is reachable and theboolean expression does not have the constant value false.The end point of a while statement is reachable if at least one of the following is true:• The while statement contains a reachable break statement that exits the while statement.• The while statement is reachable and the boolean expression does not have the constant value true.15.8.2 The do statementThe do statement conditionally executes an embedded statement one or more times.do-statement:do embedded-statement while ( boolean-expression ) ;A do statement is executed as follows:• Control is transferred to the embedded statement.• When and if control reaches the end point of the embedded statement (possibly from execution of acontinue statement), the boolean-expression (§14.16) is evaluated. If the boolean expression yieldstrue, control is transferred to the beginning of the do statement. Otherwise, control is transferred to theend point of the do statement.Within the embedded statement of a do statement, a break statement (§15.9.1) may be used to transfercontrol to the end point of the do statement (thus ending iteration of the embedded statement), and acontinue statement (§15.9.2) may be used to transfer control to the end point of the embedded statement(thus performing another iteration of the do statement).The embedded statement of a do statement is reachable if the do statement is reachable.The end point of a do statement is reachable if at least one of the following is true:• The do statement contains a reachable break statement that exits the do statement.• The end point of the embedded statement is reachable and the boolean expression does not have theconstant value true.15.8.3 The for statementThe for statement evaluates a sequence of initialization expressions and then, while a condition is true,repeatedly executes an embedded statement and evaluates a sequence of iteration expressions.for-statement:for ( for-initializer opt ; for-condition opt ; for-iterator opt ) embedded-statement187

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

Saved successfully!

Ooh no, something went wrong!