OpCodes.Ldind_Ref Field
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Loads an object reference as a type O
(object reference) onto the evaluation stack indirectly.
public: static initonly System::Reflection::Emit::OpCode Ldind_Ref;
public static readonly System.Reflection.Emit.OpCode Ldind_Ref;
staticval mutable Ldind_Ref : System.Reflection.Emit.OpCode
Public Shared ReadOnly Ldind_Ref As OpCode
The following table lists the instruction's hexadecimal and Microsoft Intermediate Language (MSIL) assembly format, along with a brief reference summary:
Format | Assembly Format | Description |
---|---|---|
50 | ldind.ref | Loads the object reference at address addr onto the stack as a type O |
The stack transitional behavior, in sequential order, is:
An address is pushed onto the stack.
The address is popped from the stack; the object reference located at the address is fetched.
The fetched reference is pushed onto the stack.
The ldind.ref
instruction indirectly loads the object reference the specified address (of type native int
, &
, or *) onto the stack as type O
.
All of the ldind
instructions are shortcuts for a Ldobj instruction that specifies the corresponding built-in value class.
Note that integer values of less than 4 bytes are extended to int32
(not native int
) when they are loaded onto the evaluation stack. Floating-point values are converted to F
type when loaded onto the evaluation stack.
Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the ldind
instructions are used in a manner consistent with the type of the pointer.
The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a NullReferenceException can occur (see the Unaligned prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, Ldloca and Ldarga) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms.
NullReferenceException can be thrown if an invalid address is detected.
The following Emit method overload can use the ldind.ref
opcode:
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: