LocalBuilder.SetLocalSymInfo Method

Definition

Sets the local variable's symbolic information.

Overloads

SetLocalSymInfo(String)

Sets the name of this local variable.

SetLocalSymInfo(String, Int32, Int32)

Sets the name and lexical scope of this local variable.

SetLocalSymInfo(String)

Sets the name of this local variable.

C#
public void SetLocalSymInfo(string name);

Parameters

name
String

The name of the local variable.

Exceptions

The containing type has been created with CreateType().

-or-

There is no symbolic writer defined for the containing module.

This local is defined in a dynamic method, rather than in a method of a dynamic type.

The name is null.

Examples

The following code sample illustrates the use of the SetLocalSymInfo method. This code is part of a larger example for the LocalBuilder class.

C#
// 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);

Remarks

The SetLocalSymInfo method is supported for methods defined in dynamic types. It is not supported for dynamic methods defined using the DynamicMethod class.

Applies to

.NET 10 dan versi lain
Produk Versi
.NET 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

SetLocalSymInfo(String, Int32, Int32)

Sets the name and lexical scope of this local variable.

C#
public void SetLocalSymInfo(string name, int startOffset, int endOffset);

Parameters

name
String

The name of the local variable.

startOffset
Int32

The beginning offset of the lexical scope of the local variable.

endOffset
Int32

The ending offset of the lexical scope of the local variable.

Exceptions

The containing type has been created with CreateType().

-or-

There is no symbolic writer defined for the containing module.

This local is defined in a dynamic method, rather than in a method of a dynamic type.

Examples

The following code sample illustrates the use of the SetLocalSymInfo method. This code is part of a larger example for the LocalBuilder class.

C#
// 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);

Remarks

The SetLocalSymInfo method is supported for methods defined in dynamic types. It is not supported for dynamic methods defined using the DynamicMethod class.

Applies to

.NET Framework 4.8.1 dan versi lain
Produk Versi
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1