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 12 Variables• Static variables.• Instance variables of class instances.• Instance variables of initially assigned struct variables.• Array elements.• Value parameters.• Reference parameters.• Variables declared in a catch clause, a foreach statement, or a using statement.12.3.2 Initially unassigned variablesThe following categories of variables are classified as initially unassigned:• Instance variables of initially unassigned struct variables.• Output parameters, including the this variable of struct instance constructors.• Local variables, except those declared in a catch clause, a foreach statement, or a using statement.12.3.3 Precise rules for determining definite assignmentIn order to determine that each used variable is definitely assigned, the compiler must use a process that isequivalent to the one described in this section.The compiler processes the body of each function member that has one or more initially unassignedvariables. For each initially unassigned variable v, the compiler determines a definite assignment state for vat each of the following points in the function member:• At the beginning of each statement• At the end point (§15.1) of each statement• On each arc which transfers control to another statement or to the end point of a statement• At the beginning of each expression• At the end of each expressionThe definite assignment state of v can be either:• Definitely assigned. This indicates that on all possible control flows to this point, v has beenassigned a value.• Not definitely assigned. For the state of a variable at the end of an expression of type bool, the stateof a variable that isn’t definitely assigned may (but doesn’t necessarily) fall into one of thefollowing sub-states:oDefinitely assigned after true expression. This state indicates that v is definitely assigned ifthe boolean expression evaluated as true, but is not necessarily assigned if the booleanexpression evaluated as false.o Definitely assigned after false expression. This state indicates that v is definitely assigned ifthe boolean expression evaluated as false, but is not necessarily assigned if the booleanexpression evaluated as true.The following rules govern how the state of a variable v is determined at each location.12.3.3.1 General rules for statements• v is not definitely assigned at the beginning of a function member body.• v is definitely assigned at the beginning of any unreachable statement.103

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

Saved successfully!

Ooh no, something went wrong!