OpCodes.Ldind_U4 字段


unsigned int32 类型的值作为 int32 间接加载到计算堆栈上。Loads a value of type unsigned int32 as an int32 onto the evaluation stack indirectly.

public: static initonly System::Reflection::Emit::OpCode Ldind_U4;
public static readonly System.Reflection.Emit.OpCode Ldind_U4;
 staticval mutable Ldind_U4 : System.Reflection.Emit.OpCode
Public Shared ReadOnly Ldind_U4 As OpCode 



下表列出了指令的十六进制和 Microsoft 中间语言(MSIL)程序集格式以及简短的参考摘要: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
4B4B ldind. u4ldind.u4 将位于地址 addr 的 @no__t 0 值作为 @no__t 加载到堆栈上。Loads the unsigned int32 value at address addr onto the stack as an int32.

堆栈转换行为顺序如下: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.

@No__t-0 指令间接地将 @no__t 1 值从指定的地址(类型为 native int& 或 *)中加载到堆栈上,以 int32 进行。The ldind.u4 instruction indirectly loads an unsigned int32 value from the specified address (of type native int, &, or *) onto the stack as an int32.

所有 ldind 指令都是指定相应内置值类的 @no__t 1 指令的快捷方式。All of the ldind instructions are shortcuts for a Ldobj instruction that specifies the corresponding built-in value class.

请注意,在将小于4个字节的整数值加载到计算堆栈上时,将其扩展到 int32 (而不是 native int)。Note that integer values of less than 4 bytes are extended to int32 (not native int) when they are loaded onto the evaluation stack. 将浮点值加载到计算堆栈上时,会将其转换为 @no__t 类型。Floating-point values are converted to F type when loaded onto the evaluation stack.

格式正确的 Microsoft 中间语言(MSIL)确保以与指针类型一致的方式使用 @no__t 的指令。Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the ldind instructions are used in a manner consistent with the type of the pointer.

最初推送到堆栈上的地址必须与计算机上对象的自然大小对齐,否则可能出现 NullReferenceException (请参阅针对预防措施的 @no__t 1 前缀指令)。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). 返回地址的所有 MSIL 指令(例如 LdlocaLdarga)的结果将安全对齐。The results of all MSIL instructions that return addresses (for example, Ldloca and Ldarga) are safely aligned. 对于大于1个字节的数据类型,字节排序依赖于目标 CPU。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.

如果检测到无效地址,则可能引发 NullReferenceExceptionNullReferenceException can be thrown if an invalid address is detected.

以下 @no__t 0 方法重载可以使用 @no__t 操作码:The following Emit method overload can use the ldind.u4 opcode:

  • ILGenerator.Emit(OpCode)ILGenerator.Emit(OpCode)