次の方法で共有


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

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

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

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
<ComVisibleAttribute(True)> _
Public Function DefineConstructor ( _
    attributes As MethodAttributes, _
    callingConvention As CallingConventions, _
    parameterTypes As Type(), _
    requiredCustomModifiers As Type()(), _
    optionalCustomModifiers As Type()() _
) As ConstructorBuilder
[SecuritySafeCriticalAttribute]
[ComVisibleAttribute(true)]
public ConstructorBuilder DefineConstructor(
    MethodAttributes attributes,
    CallingConventions callingConvention,
    Type[] parameterTypes,
    Type[][] requiredCustomModifiers,
    Type[][] optionalCustomModifiers
)

Parameters

  • parameterTypes
    Type: array<System.Type[]
    The parameter types of the constructor.
  • requiredCustomModifiers
    Type: array<array<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 nulla null reference (Nothing in Visual Basic) instead of an array of types. If none of the parameters have required custom modifiers, specify nulla null reference (Nothing in Visual Basic) instead of an array of arrays.
  • optionalCustomModifiers
    Type: array<array<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 nulla null reference (Nothing in Visual Basic) instead of an array of types. If none of the parameters have optional custom modifiers, specify nulla null reference (Nothing in Visual Basic) instead of an array of arrays.

Return Value

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

Exceptions

Exception Condition
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.

-or-

The current type is an interface.

Remarks

This overload is provided for designers of managed compilers.

NoteNote:

For more information about 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.

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.