Ldind_I Field
TOC
Collapse the table of content
Expand the table of content

OpCodes.Ldind_I Field

 

Loads a value of type native int as a native int onto the evaluation stack indirectly.

Namespace:   System.Reflection.Emit
Assembly:  mscorlib (in mscorlib.dll)

Public Shared ReadOnly Ldind_I 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

4D

ldind.i

Loads the native int value at address addr onto the stack as a native int.

The stack transitional behavior, in sequential order, is:

  1. An address is pushed onto the stack.

  2. The address is popped from the stack; the value located at the address is fetched.

  3. The fetched value is pushed onto the stack.

The ldind.i instruction indirectly loads a native int value from the specified address (of type native int, &, or *) onto the stack as a native int.

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.i opcode:

  • ILGenerator.Emit(OpCode)

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.1
Windows Phone
Available since 8.1
Return to top
Show:
© 2016 Microsoft