Mono Class Library: System.Type Overview | Members

System.Type.GetConstructor Method

Returns a public instance constructor defined in the type represented by the current instance. The parameters of the constructor match the specified argument types.

[System.Runtime.InteropServices.ComVisible(true)]
public System.Reflection.ConstructorInfo GetConstructor (Type[] types)

Parameters

types
An array of Type objects. The elements in the array are of the same number, in the same order, and represent the same types as the parameters for the constructor to be returned. Specify Type.EmptyTypes to obtain a constructor that takes no parameters.

Returns

A System.Reflection.ConstructorInfo object representing the public instance constructor whose parameters match exactly the types in types , if found; otherwise, null. If the type represented by the current instance is contained in a loaded assembly, the constructor that matches the specified criteria is not public, and the caller does not have sufficient permissions, returns null.

If the current instance represents a generic type, this method returns the System.Reflection.ConstructorInfo with the type parameters replaced by the appropriate type arguments. If the current instance represents an unassigned type parameter of a generic type or method, this method always returns null.

Permissions

TypeReason
System.Security.Permissions.ReflectionPermissionRequires permission to retrieve information on non-public members of types in loaded assemblies. See System.Security.Permissions.ReflectionPermissionFlag.TypeInformation.

Exceptions

TypeReason
ArgumentNullExceptiontypes is null, or at least one of the elements in types is null.
ArgumentExceptiontypes has more than one dimension.

Remarks

This version of Type.GetConstructor(System.Reflection.BindingFlags, System.Reflection.Binder, System.Reflection.CallingConventions, Type[], System.Reflection.ParameterModifier[]) is equivalent to Type.GetConstructor(System.Reflection.BindingFlags, System.Reflection.Binder, System.Reflection.CallingConventions, Type[], System.Reflection.ParameterModifier[])(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, null, types, null).

Requirements

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