The assignment statement stores the result of an expression in a variable. The type of the expression must be implicitly convertible to the type of the variable. At runtime, the expression on the right hand side of the assignment is evaluated first, then the variable expression. If the variable being assigned into is an array element of a reference type, a runtime check will be performed to ensure that the expression is compatible with the array element type. If the value being assigned is a Single
or a Double
and floating point error checking is on, then if the value is infinite or NaN at runtime, a System.NotFiniteNumberException
will be thrown.
It is important to note that the semantics of the assignment depend on the type of the variable being assigned to. If the variable being assigned to is a value type, then the assignment copies the value of the expression into the variable. If the variable being assigned to is a reference type, then the assignment copies the reference into the variable, not the value itself. If the type of the variable is Object
, the assignment semantics are determined by whether the expression is a value type or a reference type.
=
Expression StatementTerminator