LocalBuilder.SetLocalSymInfo 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
设置局部变量的符号信息。
重载
| 名称 | 说明 |
|---|---|
| SetLocalSymInfo(String) |
设置此局部变量的名称。 |
| SetLocalSymInfo(String, Int32, Int32) |
设置此局部变量的名称和词法范围。 |
SetLocalSymInfo(String)
- Source:
- LocalBuilder.cs
- Source:
- LocalBuilder.cs
- Source:
- LocalBuilder.cs
设置此局部变量的名称。
public:
void SetLocalSymInfo(System::String ^ name);
public void SetLocalSymInfo(string name);
member this.SetLocalSymInfo : string -> unit
Public Sub SetLocalSymInfo (name As String)
参数
- name
- String
局部变量的名称。
例外
此本地在动态方法中定义,而不是在动态类型的方法中定义。
name 是 null。
示例
下面的代码示例演示了该方法的使用 SetLocalSymInfo 。 此代码是类的较大示例的 LocalBuilder 一部分。
// Create local variables named myString and myInt.
LocalBuilder myLB1 = myMethodIL.DeclareLocal(typeof(string));
myLB1.SetLocalSymInfo("myString");
Console.WriteLine("local 'myString' type is: {0}", myLB1.LocalType);
LocalBuilder myLB2 = myMethodIL.DeclareLocal(typeof(int));
myLB2.SetLocalSymInfo("myInt", 1, 2);
Console.WriteLine("local 'myInt' type is: {0}", myLB2.LocalType);
' Create local variables named myString and myInt.
Dim myLB1 As LocalBuilder = myMethodIL.DeclareLocal(GetType(String))
myLB1.SetLocalSymInfo("myString")
Console.WriteLine("local 'myString' type is: {0}", myLB1.LocalType)
Dim myLB2 As LocalBuilder = myMethodIL.DeclareLocal(GetType(Integer))
myLB2.SetLocalSymInfo("myInt", 1, 2)
Console.WriteLine("local 'myInt' type is: {0}", myLB2.LocalType)
注解
动态 SetLocalSymInfo 类型中定义的方法支持该方法。 不支持使用 DynamicMethod 类定义的动态方法。
适用于
SetLocalSymInfo(String, Int32, Int32)
设置此局部变量的名称和词法范围。
public:
void SetLocalSymInfo(System::String ^ name, int startOffset, int endOffset);
public void SetLocalSymInfo(string name, int startOffset, int endOffset);
member this.SetLocalSymInfo : string * int * int -> unit
Public Sub SetLocalSymInfo (name As String, startOffset As Integer, endOffset As Integer)
参数
- name
- String
局部变量的名称。
- startOffset
- Int32
局部变量的词法范围的开始偏移量。
- endOffset
- Int32
局部变量的词法范围的结束偏移量。
例外
此本地在动态方法中定义,而不是在动态类型的方法中定义。
示例
下面的代码示例演示了该方法的使用 SetLocalSymInfo 。 此代码是类的较大示例的 LocalBuilder 一部分。
// Create local variables named myString and myInt.
LocalBuilder myLB1 = myMethodIL.DeclareLocal(typeof(string));
myLB1.SetLocalSymInfo("myString");
Console.WriteLine("local 'myString' type is: {0}", myLB1.LocalType);
LocalBuilder myLB2 = myMethodIL.DeclareLocal(typeof(int));
myLB2.SetLocalSymInfo("myInt", 1, 2);
Console.WriteLine("local 'myInt' type is: {0}", myLB2.LocalType);
' Create local variables named myString and myInt.
Dim myLB1 As LocalBuilder = myMethodIL.DeclareLocal(GetType(String))
myLB1.SetLocalSymInfo("myString")
Console.WriteLine("local 'myString' type is: {0}", myLB1.LocalType)
Dim myLB2 As LocalBuilder = myMethodIL.DeclareLocal(GetType(Integer))
myLB2.SetLocalSymInfo("myInt", 1, 2)
Console.WriteLine("local 'myInt' type is: {0}", myLB2.LocalType)
注解
动态 SetLocalSymInfo 类型中定义的方法支持该方法。 不支持使用 DynamicMethod 类定义的动态方法。