Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Boxes a value type.
Namespace: System.Runtime.CompilerServices
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Shared Function GetObjectValue ( _
obj As Object _
) As Object
public static Object GetObjectValue(
Object obj
)
public:
static Object^ GetObjectValue(
Object^ obj
)
static member GetObjectValue :
obj:Object -> Object
public static function GetObjectValue(
obj : Object
) : Object
Parameters
- obj
Type: System. . :: . .Object
The value type to be boxed.
Return Value
Type: System. . :: . .Object
A boxed copy of obj if it is a value class; otherwise, obj itself.
Remarks
Boxing a value type creates an object and performs a shallow copy of the fields of the specified value type into the new object.
This method allows a value class to be manipulated as an object while it retains the aliasing behavior of a value class.
The return value depends on whether the value class is mutable or immutable:
If the value being assigned is a mutable value class, the method returns a shallow copy of the class, because value classes have copy semantics.
If the value being assigned is an immutable value class, the method returns the object itself, instead of a copy of the class.
Compilers of dynamically typed languages can use this method to make sure that boxed value types work identically to unboxed value types. That is, boxed value types get cloned when you pass them around, and they are always passed by value. The compiler can call GetObjectValue to assign a value type to an object or to pass a value type as a parameter of a type object.
This method is used by compilers.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see dd66cd4c-b087-415f-9c3e-94e3a1835f74.