System.Reflection.Emit.OpCodes.Ldind_I4 Field

Loads a value of type int32 as an int32 onto the evaluation stack indirectly.

Syntax

public static readonly OpCode Ldind_I4

Remarks

The following table lists the instruction's hexadecimal and Microsoft Intermediate Language (MSIL) assembly format, along with a brief reference summary:

4A

ldind.i4

Loads the int32 value at address addr onto the stack as an int32.

The stack transitional behavior, in sequential order, is:

[The 'ordered' type of list has not been implemented in the ECMA stylesheet.]

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

All of the ldind instructions are shortcuts for a OpCodes.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 OpCodes.Unaligned prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, OpCodes.Ldloca and OpCodes.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 ILGenerator.Emit(OpCode) method overload can use the ldind.i4 opcode:

  • ILGenerator.Emit(OpCode)

Requirements

Namespace: System.Reflection.Emit
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0