Boxing is when a value type is assigned to an object type.
To close. A βboxβ occurs when a value of a value type is converted to a reference type.
Is the value of the reference type assigned to the type variable of the object?
Not. Boxing occurs when a value of a value type is converted to a reference type. Converting a value of a reference type to an object is not a conversion to boxing, it is a reference conversion.
When a reference type value (which is not an object) is assigned to an object type variable, what happens?
The value of the reference type is a reference. When a link is assigned to a variable of an type object, a copy of the link is made in the storage location associated with the variable.
Is it boxing too?
Not. Boxing occurs when a value of a value type is converted to a reference type. Converting a value of a reference type to an object is not a conversion to boxing, it is a reference conversion.
source share