OpCodes.Ldstr 字段

定义

推送对元数据中存储的字符串的新对象引用。Pushes a new object reference to a string literal stored in the metadata.

public: static initonly System::Reflection::Emit::OpCode Ldstr;
public static readonly System.Reflection.Emit.OpCode Ldstr;
 staticval mutable Ldstr : System.Reflection.Emit.OpCode
Public Shared ReadOnly Ldstr 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
72 < T >72 < T > ldstr mdTokenldstr mdToken 将元数据字符串标记的字符串对象推送 mdTokenPushes a string object for the metadata string token mdToken.

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

  1. 将对字符串的对象引用推送到堆栈上。An object reference to a string is pushed onto the stack.

@No__t-0 指令将对象引用(类型 O)推送到表示存储在元数据中的特定字符串文本的新字符串对象。The ldstr instruction pushes an object reference (type O) to a new string object representing the specific string literal stored in the metadata. @No__t-0 指令分配所需的内存量,并执行任何格式转换,以将字符串文本从文件中使用的格式转换为运行时所需的字符串格式。The ldstr instruction allocates the requisite amount of memory and performs any format conversion required to convert the string literal from the form used in the file to the string format required at runtime.

公共语言基础结构(CLI)保证两个 ldstr 指令的结果引用两个具有相同字符序列的元数据标记,这将返回完全相同的字符串对象(称为 "字符串暂留" 的过程)。The Common Language Infrastructure (CLI) guarantees that the result of two ldstr instructions referring to two metadata tokens that have the same sequence of characters return precisely the same string object (a process known as "string interning").

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

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

适用于