NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Type.GetConstructor (Type[])

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;

Parameters

types
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.

Return Value

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).

Exceptions

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.

Remarks

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.

See Also

Type Class | Type Members | System Namespace | Type.GetConstructor Overload List