LocalBuilder.SetLocalSymInfo 方法

定义

设置局部变量的符号信息。

重载

SetLocalSymInfo(String)

设置该局部变量的名称。

SetLocalSymInfo(String, Int32, Int32)

设置该局部变量的名称和词法范围。

SetLocalSymInfo(String)

设置该局部变量的名称。

public:
 void SetLocalSymInfo(System::String ^ name);
public void SetLocalSymInfo (string name);
member this.SetLocalSymInfo : string -> unit
Public Sub SetLocalSymInfo (name As String)

参数

name
String

局部变量的名称。

例外

已经用 CreateType() 创建了该包含类型。

- 或 -

没有为包含模块定义的符号编写器。

此局部变量是使用动态方法(而不是动态类型的方法)来定义的。

示例

以下代码示例演示了 方法的 SetLocalSymInfo 用法。 此代码是 类的较大示例的 LocalBuilder 一部分。

// Create local variables named myString and myInt.
LocalBuilder^ myLB1 = myMethodIL->DeclareLocal( String::typeid );
myLB1->SetLocalSymInfo( "myString" );
Console::WriteLine( "local 'myString' type is: {0}", myLB1->LocalType );

LocalBuilder^ myLB2 = myMethodIL->DeclareLocal( int::typeid );
myLB2->SetLocalSymInfo( "myInt", 1, 2 );
Console::WriteLine( "local 'myInt' type is: {0}", myLB2->LocalType );
// 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

局部变量词法范围的结束偏移量。

例外

已经用 CreateType() 创建了该包含类型。

- 或 -

没有为包含模块定义的符号编写器。

此局部变量是使用动态方法(而不是动态类型的方法)来定义的。

示例

以下代码示例演示了 方法的 SetLocalSymInfo 用法。 此代码是 类的较大示例的 LocalBuilder 一部分。

// Create local variables named myString and myInt.
LocalBuilder^ myLB1 = myMethodIL->DeclareLocal( String::typeid );
myLB1->SetLocalSymInfo( "myString" );
Console::WriteLine( "local 'myString' type is: {0}", myLB1->LocalType );

LocalBuilder^ myLB2 = myMethodIL->DeclareLocal( int::typeid );
myLB2->SetLocalSymInfo( "myInt", 1, 2 );
Console::WriteLine( "local 'myInt' type is: {0}", myLB2->LocalType );
// 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

适用于