Type.GetConstructorImpl 方法

定義

當在衍生類別中被覆寫時,會搜尋參數與指定參數類型與修飾符相符的建構子,使用指定的綁定約束與指定的呼叫慣例。

protected:
 abstract System::Reflection::ConstructorInfo ^ GetConstructorImpl(System::Reflection::BindingFlags bindingAttr, System::Reflection::Binder ^ binder, System::Reflection::CallingConventions callConvention, cli::array <Type ^> ^ types, cli::array <System::Reflection::ParameterModifier> ^ modifiers);
protected abstract System.Reflection.ConstructorInfo GetConstructorImpl(System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention, Type[] types, System.Reflection.ParameterModifier[] modifiers);
abstract member GetConstructorImpl : System.Reflection.BindingFlags * System.Reflection.Binder * System.Reflection.CallingConventions * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.ConstructorInfo
Protected MustOverride Function GetConstructorImpl (bindingAttr As BindingFlags, binder As Binder, callConvention As CallingConventions, types As Type(), modifiers As ParameterModifier()) As ConstructorInfo

參數

bindingAttr
BindingFlags

以位元組合列舉值,指定搜尋方式。

-或-

Default 返回 null

binder
Binder

一個定義一組屬性並啟用綁定的物件,綁定可能涉及選擇超載方法、強制參數類型,以及透過反射呼叫成員。

-或-

一個空參考(Nothing in Visual Basic),用來使用 DefaultBinder

callConvention
CallingConventions

指定參數順序與佈局、回傳值傳遞方式、參數使用暫存器及堆疊整理的規則集合。

types
Type[]

一個物件陣列 Type ,代表建構子要取得參數的數量、順序與類型。

-或-

一個空的陣列 Type (即 類型 = 新的類型[0]),以獲得一個不接受參數的建構子。

modifiers
ParameterModifier[]

一個代表陣列中對應元素ParameterModifier屬性的物件陣列types。 預設的綁定器不會處理這個參數。

傳回

ConstructorInfo若找到符合指定需求的建構子物件;否則,為 null

例外狀況

typesnull

-或-

其中 types 一個元素是 null

types 是多維的。

-或-

modifiers 是多維的。

-或-

typesmodifiers 長度不同。

備註

雖然預設系結器不會處理 ParameterModifiermodifiers 參數),但您可以使用抽象 System.Reflection.Binder 類來撰寫會處理 modifiers的自定義系結器。 ParameterModifier 只有在透過 COM Interop 呼叫,而且只會處理以傳址方式傳遞的參數時使用。

若不存在完全匹配的參數,則 binder 會嘗試強制陣列中指定的 types 參數類型來選擇匹配。 若 binder 無法選擇匹配,則 null 返回。

以下 BindingFlags 過濾標誌可用來定義搜尋中應包含哪些建構子:

  • 您必須指定 BindingFlags.InstanceBindingFlags.Static ,才能取得傳回。

  • 請指定 BindingFlags.Public 在搜尋中包含公開建構器。

  • 請指定 BindingFlags.NonPublic 在搜尋中包含非公開建構子(即私有建構子、內部建構子及受保護建構子)。

如需相關資訊,請參閱 System.Reflection.BindingFlags

這個方法會實作 GetConstructor

適用於

另請參閱