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.

<strong>C#</strong> LANGUAGE SPECIFICATION• The definite assignment state of v at the beginning of any other statement is determined by checkingthe definite assignment state of v on all control flow transfers that target the beginning of thatstatement. If (and only if) v is definitely assigned on all such control flow transfers, then v isdefinitely assigned at the beginning of the statement. The set of possible control flow transfers isdetermined in the same way as for checking statement reachability (§15.1).• The definite assignment state of v at the end point of a block, checked, unchecked, if, while,do, for, foreach, lock, using, or switch statement is determined by checking the definiteassignment state of v on all control flow transfers that target the end point of that statement. If v isdefinitely assigned on all such control flow transfers, then v is definitely assigned at the end point ofthe statement. Otherwise, v is not definitely assigned at the end point of the statement. The set ofpossible control flow transfers is determined in the same way as for checking statement reachability(§15.1).12.3.3.2 Block statements, checked, and unchecked statementsThe definite assignment state of v on the control transfer to the first statement of the statement list in theblock (or to the end point of the block, if the statement list is empty) is the same as the definite assignmentstatement of v before the block, checked, or unchecked statement.12.3.3.3 Expression statementsFor an expression statement stmt that consists of the expression expr:• v has the same definite assignment state at the beginning of expr as at the beginning of stmt.• If v if definitely assigned at the end of expr, it is definitely assigned at the end point of stmt;otherwise; it is not definitely assigned at the end point of stmt.12.3.3.4 Declaration statements• If stmt is a declaration statement without initializers, then v has the same definite assignment state atthe end point of stmt as at the beginning of stmt.• If stmt is a declaration statement with initializers, then the definite assignment state for v isdetermined as if stmt were a statement list, with one assignment statement for each declaration withan initializer (in the order of declaration).12.3.3.5 If statementsFor an if statement stmt of the form:if (expr) then-stmt else else-stmt• v has the same definite assignment state at the beginning of expr as at the beginning of stmt.• If v is definitely assigned at the end of expr, then it is definitely assigned on the control flow transferto then-stmt and to either else-stmt or to the end-point of stmt if there is no else clause.• If v has the state “definitely assigned after true expression” at the end of expr, then it is definitelyassigned on the control flow transfer to then-stmt, and not definitely assigned on the control flowtransfer to either else-stmt or to the end-point of stmt if there is no else clause.• If v has the state “definitely assigned after false expression” at the end of expr, then it is definitelyassigned on the control flow transfer to else-stmt, and not definitely assigned on the control flowtransfer to then-stmt. It is definitely assigned at the end-point of stmt if and only if it is definitelyassigned at the end-point of then-stmt.• Otherwise, v is considered not definitely assigned on the control flow transfer to either the then-stmtor else-stmt, or to the end-point of stmt if there is no else clause.104

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

Saved successfully!

Ooh no, something went wrong!