This documentation is archived and is not being maintained.

ConstructorBuilder.GetParameters Method

Returns the parameters of this constructor.

Namespace:  System.Reflection.Emit
Assembly:  mscorlib (in mscorlib.dll)

public override ParameterInfo[] GetParameters()

Return Value

Type: System.Reflection.ParameterInfo[]
Returns an array of ParameterInfo objects that represent the parameters of this constructor.




CreateType has not been called on this constructor's type, in the .NET Framework versions 1.0 and 1.1.


CreateType has not been called on this constructor's type, in the .NET Framework version 2.0.

This property is not supported until after the TypeBuilder.CreateType method has been called. In the .NET Framework versions 1.0 and 1.1, InvalidOperationException is thrown. In the .NET Framework version 2.0, NotSupportedException is thrown.

The code sample illustrates the use of GetParameters.

// Define a constructor of the dynamic class.
ConstructorBuilder myConstructorBuilder = myTypeBuilder.DefineConstructor(
   MethodAttributes.Public, CallingConventions.Standard, myConstructorArgs);
// Get a reference to the module that contains this constructor.
Module myModule = myConstructorBuilder.GetModule();
Console.WriteLine("Module Name : " + myModule.Name);
// Get the 'MethodToken' that represents the token for this constructor.
MethodToken myMethodToken = myConstructorBuilder.GetToken();
Console.WriteLine("Constructor Token is : " + myMethodToken.Token);
// Get the method implementation flags for this constructor.
MethodImplAttributes myMethodImplAttributes = myConstructorBuilder.GetMethodImplementationFlags();
Console.WriteLine("MethodImplAttributes : "  + myMethodImplAttributes);
// Generate IL for the method, call its base class constructor and store the arguments
// in the private field.
ILGenerator myILGenerator3 = myConstructorBuilder.GetILGenerator();
ConstructorInfo myConstructorInfo = typeof(Object).GetConstructor(new Type[0]);
myILGenerator3.Emit(OpCodes.Call, myConstructorInfo);
myILGenerator3.Emit(OpCodes.Stfld, myGreetingField);
// Add a method to the type.
myMethodBuilder = myTypeBuilder.DefineMethod
// Generate IL for the method.
ILGenerator myILGenerator2 = myMethodBuilder.GetILGenerator();
myILGenerator2.EmitWriteLine("Hello World from global");
myType1 = myTypeBuilder.CreateType();

// Get the parameters of this constructor.
ParameterInfo[] myParameterInfo = myConstructorBuilder.GetParameters();
for(int i =0 ; i < myParameterInfo.Length; i++)
   Console.WriteLine("Declaration type : " + myParameterInfo[i].Member.DeclaringType);

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.