public abstract class ConstructorInfo : MethodBase
Object
MemberInfo
MethodBase
ConstructorInfo
mscorlib
Reflection
Provides access to constructor metadata.
System.Reflection Namespace
ConstructorInfo Constructors
ConstructorInfo Methods
ConstructorInfo.Invoke(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo) Method
ConstructorInfo.Invoke(System.Object[]) Method
ConstructorInfo Fields
ConstructorInfo.ConstructorName Field
ConstructorInfo.TypeConstructorName Field
protected ConstructorInfo();
Constructs a new instance of the ConstructorInfo class.
System.Reflection.ConstructorInfo Class, System.Reflection Namespace
public abstract object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture);
Invokes the constructor reflected by the current instance using the specified arguments, under the constraints of the specified Binder .
- invokeAttr
- A BindingFlags value that controls the binding process.
- binder
- A Binder that defines a set of properties and enables the binding, coercion of argument types, and invocation of members using reflection. If binder is
null
, then the default binder is used.- parameters
- An array of objects that match the number, order and type of the parameters for the constructor reflected by the current instance. If the constructor reflected by the current instance takes no parameters, specify either an array with zero elements or
null
. [Note: Any object in this array that is not explicitly initialized with a value will contain the default value for that object type. For reference-type elements, this value isnull
. For value-type elements, this value is 0, 0.0, orfalse
, depending on the specific element type.]
- culture
- The only defined value for this parameter is
null
.
An instance of the class that declared the constructor reflected by the current instance.
Exception Type Condition ArgumentException The types of the elements of parameters do not match the types of the parameters accepted by the constructor reflected by the current instance, under the constraints of binder. MethodAccessException The caller does not have the required permissions. TargetInvocationException The constructor reflected by the current instance threw an exception. TargetParameterCountException parameters.Length does not equal the number of parameters required by the contract of the constructor reflected by the current instance.
[Behaviors: Before calling the constructor, this method ensures that the caller has access permission and that the parameters are of the correct number, order and type.]
System.Reflection.ConstructorInfo Class, System.Reflection Namespace
public object Invoke(object[] parameters);
Invokes the constructor reflected by the current instance using the specified parameters.
- parameters
- An array of objects that match the number, order and type of the parameters for the constructor reflected by the current instance. If the constructor reflected by the current instance takes no parameters, specify either an array with zero elements or
null
. [Note: Any object in this array that is not explicitly initialized with a value will contain the default value for that object type. For reference-type elements, this value isnull
. For value-type elements, this value is 0, 0.0, orfalse
, depending on the specific element type.]
An instance of the class that declared the constructor reflected by the current instance.
Exception Type Condition ArgumentException The types of the elements of parameters do not match the types of the parameters accepted by the constructor reflected by the current instance, under the constraints of the default binder.
MethodAccessException The caller does not have the required permissions. TargetInvocationException The constructor reflected by the current instance threw an exception. TargetParameterCountException parameters.Length does not equal the number of parameters required by the contract of the constructor reflected by the current instance.
System.Reflection.ConstructorInfo Class, System.Reflection Namespace
public static readonly string ConstructorName;
A string containing the name of an object constructor as it is stored in metadata.
This field is read-only.This field is a String that contains the value ".ctor". An object constructor will be named with this field if and only if it is not a type initializer.
[Note: For more information on type initializers, see System.Reflection.ConstructorInfo.TypeConstructorName.
For more information on object constructors, see Partition II of the CLI Specification.
]
System.Reflection.ConstructorInfo Class, System.Reflection Namespace
public static readonly string TypeConstructorName;
A string containing the name of a type initializer as it is stored in metadata.
This field is read-only.This field is a String that contains the value ".cctor".
[Note: A type initializer can be applied to all types. It allows the type to perform any initialization required before any members declared within the type are accessed. Type initializers accept no parameters and always have a return type of void. A type constructor only has access to a type's static fields and its usual purpose is to initialize those fields. A type's constructor is guaranteed to run before any instance of the type is created and before any static field or method of the type is referenced.
Many languages (including C#) automatically generate type constructors for all implementer-defined types. However, some languages require that type constructors be explicitly implemented.
For more information on type initializers, see Partition II of the CLI Specification.
]
System.Reflection.ConstructorInfo Class, System.Reflection Namespace