System.Type.GetConstructors Method

Returns all the public constructors defined for the current Type.

Syntax

[System.Runtime.InteropServices.ComVisible(true)]
public System.Reflection.ConstructorInfo[] GetConstructors ()

Returns

An array of System.Reflection.ConstructorInfo objects representing all the public instance constructors defined for the current Type, but not including the type initializer (static constructor). If no public instance constructors are defined for the current Type, or if the current Type represents a type parameter in the definition of a generic type or generic method, an empty array of type System.Reflection.ConstructorInfo is returned.

Remarks

The Type.GetConstructors method does not return constructors in a particular order, such as declaration order. Your code must not depend on the order in which constructors are returned, because that order varies.

The following table shows what members of a base class are returned by the Get methods when reflecting on a type.

Constructor

No

No

Field

No

Yes. A field is always hide-by-name-and-signature.

Event

Not applicable

The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.

Method

No

Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.

Nested Type

No

No

Property

Not applicable

The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.

[The 'ordered' type of list has not been implemented in the ECMA stylesheet.]

This method overload calls the Type.GetConstructors(System.Reflection.BindingFlags) method overload, with System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance (System.Reflection.BindingFlags.Public Or System.Reflection.BindingFlags.Instance in Visual Basic). It will not find class initializers (.cctor). To find class initializers, use an overload that takes System.Reflection.BindingFlags, and specify System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic (System.Reflection.BindingFlags.Static Or System.Reflection.BindingFlags.NonPublic in Visual Basic). You can also get the class initializer using the Type.TypeInitializer property.

If the current Type represents a constructed generic type, this method returns the System.Reflection.ConstructorInfo objects with the type parameters replaced by the appropriate type arguments. For example, if class C<T> has a constructor C(T t1) (Sub New(ByVal t1 As T) in Visual Basic), calling Type.GetConstructors on C<int> returns a System.Reflection.ConstructorInfo that represents C(int t1) in C# (Sub New(ByVal t1 As Integer) in Visual Basic).

If the current Type represents a generic type parameter, the Type.GetConstructors method returns an empty array.

Requirements

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