9.2.3.2 Instance variables in classesĪn instance variable of a class comes into existence when a new instance of that class is created, and ceases to exist when there are no references to that instance and the instance’s finalizer (if any) has executed. 9.2.3 Instance variables 9.2.3.1 GeneralĪ field declared without the static modifier is an instance variable. The initial value of a static variable is the default value ( §9.3) of the variable’s type.įor the purposes of definite-assignment checking, a static variable is considered initially assigned. A static variable comes into existence before execution of the static constructor ( §15.12) for its containing type, and ceases to exist when the associated application domain ceases to exist. end example 9.2.2 Static variablesĪ field declared with the static modifier is a static variable. X is a static variable, y is an instance variable, v is an array element, a is a value parameter, b is a reference parameter, c is an output parameter, d is an input parameter, and i is a local variable. Void F(int v, int a, ref int b, out int c, in int d) The subclauses that follow describe each of these categories. 9.2 Variable categories 9.2.1 GeneralĬ# defines eight categories of variables: static variables, instance variables, array elements, value parameters, input parameters, reference parameters, output parameters, and local variables. For an initially unassigned variable to be considered definitely assigned at a certain location, an assignment to the variable shall occur in every possible execution path leading to that location. An initially unassigned variable has no initial value. ![]() An initially assigned variable has a well-defined initial value and is always considered definitely assigned. The value of a variable can be changed through assignment or through use of the ++ and - operators.Ī variable shall be definitely assigned ( §9.4) before its value can be obtained.Īs described in the following subclauses, variables are either initially assigned or initially unassigned. C# is a type-safe language, and the C# compiler guarantees that values stored in variables are always of the appropriate type. Every variable has a type that determines what values can be stored in the variable.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |