OpCodes.Stsfld 字段


用来自计算堆栈的值替换静态字段的值。Replaces the value of a static field with a value from the evaluation stack.

public: static initonly System::Reflection::Emit::OpCode Stsfld;
public static readonly System.Reflection.Emit.OpCode Stsfld;
 staticval mutable Stsfld : System.Reflection.Emit.OpCode
Public Shared ReadOnly Stsfld 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
80 < T >80 < T > stsfld fieldstsfld field field 中的值替换为提供的值。Replaces the value in field with a supplied value.

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

  1. 将值推送到堆栈上。A value is pushed onto the stack.

  2. 将从堆栈中弹出一个值并将其存储在 fieldA value is popped from the stack and stored in field.

@No__t-0 指令用堆栈中的值替换静态字段的值。The stsfld instruction replaces the value of a static field with a value from the stack. field 是必须引用静态字段成员的元数据标记。field is a metadata token that must refer to a static field member.

@No__t-0 指令可能以 @no__t 为前缀。The stsfld instruction may be prefixed by Volatile.

如果在元数据中找不到字段,则会引发 MissingFieldExceptionMissingFieldException is thrown if field is not found in the metadata. 当 Microsoft 中间语言(MSIL)指令转换为本机代码而不是在运行时,通常会检查此情况。This is typically checked when Microsoft Intermediate Language (MSIL) instructions are converted to native code, not at run time.

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

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