April 2014
Intermediate to advanced
960 pages
22h 9m
English
The following code shows the syntax for declaring a variable inside a method.
«const» type«[]» name «= value»;
The following list describes the pieces of this declaration.
const—If you include this, the variable is a constant and its value cannot be changed later. Use the value to assign the constant a value.[]—Include empty square brackets [] to make an array.= value—The value you want the variable to initially have.C# enables you to declare and initialize more than one variable in a single declaration statement, but this can make the code more difficult to read.
The following code shows the syntax for declaring a variable outside of any method (at the class level).
«attributes» «accessibility»
«const | readonly | static | volatile | static volatile»
type«[]» name «= value»
The following list describes the pieces of this declaration.
public, internal, protected, internal protected, or private. The default is private.const—If you include this, the variable is a constant and its value cannot be changed later. Use the value to assign the constant a value.readonly—If you include this, the variable is similar to a constant except its value can be set either with a value clause or in the class’s constructor.static—This keyword indicates the variable is shared ...Read now
Unlock full access