OpCodes.Stfld 字段

定义

用新值替换在对象引用或指针的字段中存储的值。Replaces the value stored in the field of an object reference or pointer with a new value.

public: static initonly System::Reflection::Emit::OpCode Stfld;
public static readonly System.Reflection.Emit.OpCode Stfld;
 staticval mutable Stfld : System.Reflection.Emit.OpCode
Public Shared ReadOnly Stfld 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
7D < T >7D < T > stfld fieldstfld field 将对象 @no__t 的值替换为新值。Replaces the value of field of the object with a new value.

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

  1. 对象引用或指针被推送到堆栈上。An object reference or pointer is pushed onto the stack.

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

  3. 从堆栈中弹出值和对象引用/指针;对象中 field 的值将替换为提供的值。The value and the object reference/pointer are popped from the stack; the value of field in the object is replaced with the supplied value.

@No__t-0 指令替换对象(类型 O)或通过指针(类型为 native int&*)的字段的值,具有给定值。The stfld instruction replaces the value of a field of an object (type O) or via a pointer (type native int, &, or *) with a given value. Field 是引用字段成员引用的元数据标记。Field is a metadata token that refers to a field member reference. @No__t-0 指令可以具有 Unaligned 和/或 @no__t 的前缀。The stfld instruction can have a prefix of either or both of Unaligned and Volatile.

如果对象引用或指针为空引用,并且该字段不是静态的,则会引发 NullReferenceExceptionNullReferenceException is thrown if the object reference or pointer is a null reference and the field isn't static.

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

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

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

适用于