Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

TypeBuilder.DefineDefaultConstructor Method

Defines the default constructor. The constructor defined here will simply call the default constructor of the parent.

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

[ComVisibleAttribute(true)]
public ConstructorBuilder DefineDefaultConstructor(
	MethodAttributes attributes
)

Parameters

attributes
Type: System.Reflection.MethodAttributes
A MethodAttributes object representing the attributes to be applied to the constructor.

Return Value

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

ExceptionCondition
NotSupportedException

The parent type (base type) does not have a default constructor.

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.

Because the default constructor is automatically defined, it is necessary to call this method only in the following situations:

  • You have defined another constructor and you also want a default constructor that simply calls the base class constructor.

  • You want to set the attributes on the default constructor to something other than PrivateScope, Public, HideBySig, SpecialName, and RTSpecialName.

Silverlight

Supported in: 5, 4, 3

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

Community Additions

ADD
Show:
© 2015 Microsoft