_Type.GetConstructor Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides COM objects with version-independent access to the GetConstructor method.
Overloads
GetConstructor(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[]) |
Provides COM objects with version-independent access to the GetConstructor(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[]) method. |
GetConstructor(BindingFlags, Binder, Type[], ParameterModifier[]) |
Provides COM objects with version-independent access to the GetConstructor(BindingFlags, Binder, Type[], ParameterModifier[]) method. |
GetConstructor(Type[]) |
Provides COM objects with version-independent access to the GetConstructor(Type[]) method. |
Remarks
This method is for access to managed classes from unmanaged code, and should not be called from managed code.
The Type.GetConstructor method gets a specific constructor of the current Type.
GetConstructor(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])
Provides COM objects with version-independent access to the GetConstructor(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[]) method.
public:
System::Reflection::ConstructorInfo ^ GetConstructor(System::Reflection::BindingFlags bindingAttr, System::Reflection::Binder ^ binder, System::Reflection::CallingConventions callConvention, cli::array <Type ^> ^ types, cli::array <System::Reflection::ParameterModifier> ^ modifiers);
public System.Reflection.ConstructorInfo GetConstructor (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention, Type[] types, System.Reflection.ParameterModifier[] modifiers);
abstract member GetConstructor : System.Reflection.BindingFlags * System.Reflection.Binder * System.Reflection.CallingConventions * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.ConstructorInfo
Public Function GetConstructor (bindingAttr As BindingFlags, binder As Binder, callConvention As CallingConventions, types As Type(), modifiers As ParameterModifier()) As ConstructorInfo
Parameters
- bindingAttr
- BindingFlags
A bitmask comprised of one or more BindingFlags that specify how the search is conducted.
-or-
Zero, to return null
.
- binder
- Binder
A Binder object that defines a set of properties and enables binding, which can involve selection of an overloaded method, coercion of argument types, and invocation of a member through reflection.
-or-
null
, to use the DefaultBinder.
- callConvention
- CallingConventions
The CallingConventions object that specifies the set of rules to use regarding the order and layout of arguments, how the return value is passed, what registers are used for arguments, and the stack is cleaned up.
- types
- Type[]
An array of Type objects representing the number, order, and type of the parameters for the constructor to get.
-or-
An empty array of the type Type (that is, Type[] types = new Type[0]) to get a constructor that takes no parameters.
- modifiers
- ParameterModifier[]
An array of ParameterModifier objects representing the attributes associated with the corresponding element in the types
array. The default binder does not process this parameter.
Returns
A ConstructorInfo object representing the constructor that matches the specified requirements, if found; otherwise, null
.
Remarks
This method is for access to managed classes from unmanaged code, and should not be called from managed code.
The Type.GetConstructor method searches for a constructor whose parameters match the specified argument types and modifiers, using the specified binding constraints and the specified calling convention.
Applies to
GetConstructor(BindingFlags, Binder, Type[], ParameterModifier[])
Provides COM objects with version-independent access to the GetConstructor(BindingFlags, Binder, Type[], ParameterModifier[]) method.
public:
System::Reflection::ConstructorInfo ^ GetConstructor(System::Reflection::BindingFlags bindingAttr, System::Reflection::Binder ^ binder, cli::array <Type ^> ^ types, cli::array <System::Reflection::ParameterModifier> ^ modifiers);
public System.Reflection.ConstructorInfo GetConstructor (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, Type[] types, System.Reflection.ParameterModifier[] modifiers);
abstract member GetConstructor : System.Reflection.BindingFlags * System.Reflection.Binder * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.ConstructorInfo
Public Function GetConstructor (bindingAttr As BindingFlags, binder As Binder, types As Type(), modifiers As ParameterModifier()) As ConstructorInfo
Parameters
- bindingAttr
- BindingFlags
A bitmask comprised of one or more BindingFlags that specify how the search is conducted.
-or-
Zero, to return null
.
- binder
- Binder
A Binder object that defines a set of properties and enables binding, which can involve selection of an overloaded method, coercion of argument types, and invocation of a member through reflection.
-or-
null
, to use the DefaultBinder.
- types
- Type[]
An array of Type objects representing the number, order, and type of the parameters for the constructor to get.
-or-
An empty array of the type Type (that is, Type[] types = new Type[0]) to get a constructor that takes no parameters.
-or-
- modifiers
- ParameterModifier[]
An array of ParameterModifier objects representing the attributes associated with the corresponding element in the parameter type array. The default binder does not process this parameter.
Returns
A ConstructorInfo object representing the constructor that matches the specified requirements, if found; otherwise, null
.
Remarks
This method is for access to managed classes from unmanaged code, and should not be called from managed code.
The Type.GetConstructor method searches for a constructor whose parameters match the specified argument types and modifiers, using the specified binding constraints.
Applies to
GetConstructor(Type[])
Provides COM objects with version-independent access to the GetConstructor(Type[]) method.
public:
System::Reflection::ConstructorInfo ^ GetConstructor(cli::array <Type ^> ^ types);
public System.Reflection.ConstructorInfo GetConstructor (Type[] types);
abstract member GetConstructor : Type[] -> System.Reflection.ConstructorInfo
Public Function GetConstructor (types As Type()) As ConstructorInfo
Parameters
- types
- 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 EmptyTypes.
Returns
A ConstructorInfo object representing the public instance constructor whose parameters match the types in the parameter type array, if found; otherwise, null
.
Remarks
This method is for access to managed classes from unmanaged code, and should not be called from managed code.
The Type.GetConstructor method searches for a public instance constructor whose parameters match the types in the specified array.