Export (0) Print
Expand All

TypeBuilder.DefineConstructor Method (MethodAttributes, CallingConventions, Type[], Type[][], Type[][])

Adds a new constructor to the type, with the given attributes, signature, and custom modifiers.

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

[ComVisibleAttribute(true)]
public ConstructorBuilder DefineConstructor(
	MethodAttributes attributes,
	CallingConventions callingConvention,
	Type[] parameterTypes,
	Type[][] requiredCustomModifiers,
	Type[][] optionalCustomModifiers
)

Parameters

attributes
Type: System.Reflection.MethodAttributes
The attributes of the constructor.
callingConvention
Type: System.Reflection.CallingConventions
The calling convention of the constructor.
parameterTypes
Type: System.Type[]
The parameter types of the constructor.
requiredCustomModifiers
Type: System.Type[][]
An array of arrays of types. Each array of types represents the required custom modifiers for the corresponding parameter, such as IsConst. If a particular parameter has no required custom modifiers, specify null instead of an array of types. If none of the parameters have required custom modifiers, specify null instead of an array of arrays.
optionalCustomModifiers
Type: System.Type[][]
An array of arrays of types. Each array of types represents the optional custom modifiers for the corresponding parameter, such as IsConst. If a particular parameter has no optional custom modifiers, specify null instead of an array of types. If none of the parameters have optional custom modifiers, specify null instead of an array of arrays.

Return Value

Type: System.Reflection.Emit.ConstructorBuilder
The defined constructor.

ExceptionCondition
ArgumentException

The size of requiredCustomModifiers or optionalCustomModifiers does not equal the size of parameterTypes.

InvalidOperationException

The type was previously created using CreateType.

-or-

For the current dynamic type, the IsGenericType property is true, but the IsGenericTypeDefinition property is false.

This overload is provided for designers of managed compilers.

NoteNote

For more information on custom modifiers, see the ECMA Partition II Metadata documentation. The documentation is available online; see ECMA C# and Common Language Infrastructure Standards on MSDN and Standard ECMA-335 - Common Language Infrastructure (CLI) on the Ecma International Web site.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.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.

Community Additions

ADD
Show:
© 2014 Microsoft