OpCodes.Ldobj 字段


将地址指向的值类型对象复制到计算堆栈的顶部。Copies the value type object pointed to by an address to the top of the evaluation stack.

public: static initonly System::Reflection::Emit::OpCode Ldobj;
public static readonly System.Reflection.Emit.OpCode Ldobj;
 staticval mutable Ldobj : System.Reflection.Emit.OpCode
Public Shared ReadOnly Ldobj 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
71 < T >71 < T > ldobj classldobj class 将值类型 class 的实例复制到堆栈。Copy instance of value type class to the stack.

堆栈转换行为顺序如下:The stack transitional behavior, in sequential order, is:

  1. 值类型对象的地址被推送到堆栈上。The address of a value type object is pushed onto the stack.

  2. 从堆栈中弹出该地址,并查找该特定地址处的实例。The address is popped from the stack and the instance at that particular address is looked up.

  3. 存储在该地址的对象的值被推送到堆栈上。The value of the object stored at that address is pushed onto the stack.

@No__t-0 指令用于作为参数传递值类型。The ldobj instruction is used to pass a value type as a parameter.

@No__t-0 指令将 @no__t 的值(类型 &*native int)复制到堆栈顶部。The ldobj instruction copies the value pointed to by addrOfValObj (of type &, *, or native int) to the top of the stack. 已复制的字节数取决于类的大小(由 class 参数指定)。The number of bytes copied depends on the size of the class (as specified by the class parameter). @No__t 参数是表示值类型的元数据标记。The class parameter is a metadata token representing the value type.

紧靠前 @no__t 或 Unaligned 前缀指令可以更改 ldobj 指令的操作。The operation of the ldobj instruction can be altered by an immediately preceding Volatile or Unaligned prefix instruction.

如果找不到类,则会引发 TypeLoadExceptionTypeLoadException is thrown if class cannot be found. 当 Microsoft 中间语言(MSIL)指令转换为本机代码而不是运行时,通常会检测到此情况。This is typically detected when the Microsoft Intermediate Language (MSIL) instruction is converted to native code rather than at runtime.

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

  • ILGenerator (OpCode,Type)ILGenerator.Emit(OpCode, Type)