OpCodes.Stobj 字段


将指定类型的值从计算堆栈复制到所提供的内存地址中。Copies a value of a specified type from the evaluation stack into a supplied memory address.

public: static initonly System::Reflection::Emit::OpCode Stobj;
public static readonly System.Reflection.Emit.OpCode Stobj;
 staticval mutable Stobj : System.Reflection.Emit.OpCode
Public Shared ReadOnly Stobj 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
81 < T >81 < T > stobj classstobj class 将类型的值从堆栈存储到内存中,@no__t 0。Stores a value of type class from the stack into memory.

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

  1. 地址被推送到堆栈上。An address is pushed onto the stack.

  2. 类型 class 的值类型对象被推送到堆栈上。A value type object of type class is pushed onto the stack.

  3. 从堆栈中弹出对象和地址;值类型对象存储在地址上。The object and the address are popped from the stack; the value type object is stored at the address.

@No__t-0 指令将值类型对象复制到地址指定的地址中(类型为的指针 native int*&)。The stobj instruction copies the value type object into the address specified by the address (a pointer of type native int, *, or &). 已复制的字节数取决于由 class 表示的类的大小,即表示值类型的元数据标记。The number of bytes copied depends on the size of the class represented by class, a metadata token representing a value type.

紧靠前 @no__t 或 Unaligned 前缀指令可以更改 stobj 指令的操作。The operation of the stobj 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 Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at run time.

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

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