System.Reflection.Emit.ILGenerator.DeclareLocal Method

Declares a local variable of the specified type.

Syntax

public virtual LocalBuilder DeclareLocal (Type localType)

Parameters

localType
A Type object that represents the type of the local variable.

Returns

The declared local variable.

Remarks

The local variable is created in the current lexical scope; for example, if code is being emitted in a for loop (For loop in Visual Basic), the scope of the variable is the loop.

A local variable created with this overload is not pinned. To create a pinned variable for use with unmanaged pointers, use the ILGenerator.DeclareLocal(Type, bool) method overload.

Requirements

Namespace: System.Reflection.Emit
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0