Share via


GetConstructor Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

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

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

Syntax

'Declaration
Public Function GetConstructor ( _
    types As Type() _
) As ConstructorInfo
public ConstructorInfo GetConstructor(
    Type[] types
)
public:
ConstructorInfo^ GetConstructor(
    array<Type^>^ types
)
member GetConstructor : 
        types:Type[] -> ConstructorInfo 
public function GetConstructor(
    types : Type[]
) : ConstructorInfo

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
An object representing the public instance constructor whose parameters match the types in the parameter type array, if found; otherwise, nullNothingnullptrunita null reference (Nothing in Visual Basic).

Remarks

If the requested constructor is non-public, this method returns null Nothing nullptr unit a null reference (Nothing in Visual Basic) .

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 null Nothing nullptr unit a null reference (Nothing in Visual Basic) .

.NET Framework Security

See Also

Reference

Type Class

System Namespace