Type::GetConstructor Method (array<Type>)

Searches for a public instance constructor whose parameters match the types in the specified array.

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

No code example is currently available or this language may not be supported.

Parameters

types
Type: array<System::Type>
An array of Type objects representing the number, order, and type of the parameters for the desired constructor.
-or-
An empty array of Type objects, to get a constructor that takes no parameters. Such an empty array is provided by the static field Type::EmptyTypes.

Return Value

Type: System.Reflection::ConstructorInfo
A ConstructorInfo object representing the public instance constructor whose parameters match the types in the parameter type array, if found; otherwise, nullptr.

ExceptionCondition
ArgumentNullException

types is nullptr.

-or-

One of the elements in types is nullptr.

ArgumentException

types is multidimensional.

This method overload looks for public instance constructors and cannot be used to obtain a class initializer (.cctor). To get a class initializer, use an overload that takes BindingFlags, and specify BindingFlags::Static | BindingFlags::NonPublic (BindingFlags::Static Or BindingFlags::NonPublic in Visual Basic).

If the requested constructor is non-public, this method returns nullptr.

NoteNote:

You cannot omit parameters when looking up constructors and methods. You can only omit parameters when invoking.

If the current Type represents a constructed generic type, this method returns the ConstructorInfo with the type parameters replaced by the appropriate type arguments. If the current Type represents a type parameter in the definition of a generic type or generic method, this method always returns nullptr.

The following example obtains the type of MyClass, gets the ConstructorInfo object, and displays the constructor signature.

No code example is currently available or this language may not be supported.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

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

Community Additions

ADD
Show: