Searches for a constructor whose parameters match the types in the specified array.
[Visual Basic] Overloads Public Function GetConstructor( _ ByVal types() As Type _ ) As ConstructorInfo [C#] public ConstructorInfo GetConstructor( Type[] types ); [C++] public: ConstructorInfo* GetConstructor( Type* types[] ); [JScript] public function GetConstructor( types : Type[] ) : ConstructorInfo;
-or-
An empty array of the type Type (that is, Type[] types = new Type[0]) to get a constructor that takes no parameters.
A ConstructorInfo object representing the constructor whose parameters match the types in the types array, if found; otherwise, a null reference (in Visual Basic Nothing).
Exception Type | Condition |
---|---|
ArgumentNullException | types is a null reference (Nothing).
-or- One of the elements in types is a null reference (Nothing). |
ArgumentException | types is multidimensional.
(?) |
SecurityException | The requested constructor is non-public and the caller does not have ReflectionPermission to reflect non-public constructors outside the current assembly. |
If an exact match can be found, then it is returned. If an exact match does not exist, the binder will attempt to coerce the parameter types specified in the types array in order to select a match. If it is not possible to select a match, then null is returned. GetConstructor cannot be used to obtain a class initializer. Class initializers are available only through GetMember, GetMembers, FindMembers, and GetConstructors.
Type Class | Type Members | System Namespace | Type.GetConstructor Overload List