Type.GetConstructorImpl(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[]) Type.GetConstructorImpl(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[]) Type.GetConstructorImpl(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[]) Method

定義

在衍生類別中覆寫時,使用指定的繫結條件約束和指定的呼叫慣例,搜尋其參數符合指定的引數類型和修飾詞的建構函式。When overridden in a derived class, searches for a constructor whose parameters match the specified argument types and modifiers, using the specified binding constraints and the specified calling convention.

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

參數

bindingAttr
BindingFlags BindingFlags BindingFlags

列舉值的位元組合,用來指定搜尋的執行方式。A bitwise combination of the enumeration values that specify how the search is conducted.

-或--or- 要傳回 nullDefaultDefault to return null.

binder
Binder Binder Binder

定義一組屬性並啟用繫結的物件,可包含多載方法的選擇、引數類型的強制,以及透過反映的成員引動過程。An 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 參考 (在 Visual Basic 中為 Nothing),可使用 DefaultBinderA null reference (Nothing in Visual Basic), to use the DefaultBinder.

callConvention
CallingConventions CallingConventions CallingConventions

物件,其指定一組所要使用的規則,而這些規則是關於引數的順序和配置、如何傳遞傳回值、引數使用哪些暫存器以及清除堆疊。The 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[]

Type 物件的陣列,代表所要取得之建構函式的參數數目、順序和類型。An array of Type objects representing the number, order, and type of the parameters for the constructor to get.

-或--or- 用以取得沒有參數的建構函式之 Type 類型的空陣列 (也就是,Type[] types = new Type[0])。An empty array of the type Type (that is, Type[] types = new Type[0]) to get a constructor that takes no parameters.

modifiers
ParameterModifier[]

ParameterModifier 物件的陣列,代表在 types 陣列中與對應項目關聯的屬性。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.

傳回

ConstructorInfo 物件,代表符合指定之需求的建構函式 (如有找到);否則為 nullA ConstructorInfo object representing the constructor that matches the specified requirements, if found; otherwise, null.

例外狀況

typesnulltypes is null.

-或--or- types 的其中一個項目為 nullOne of the elements in types is null.

types 是多維的。types is multidimensional.

-或--or- modifiers 是多維的。modifiers is multidimensional.

-或--or- typesmodifiers 的長度不同。types and modifiers do not have the same length.

備註

雖然預設繫結器不會處理ParameterModifier(modifiers參數),您可以使用抽象System.Reflection.Binder類別,以寫入未處理的自訂繫結器modifiersAlthough the default binder does not process ParameterModifier (the modifiers parameter), you can use the abstract System.Reflection.Binder class to write a custom binder that does process modifiers. ParameterModifier 透過 COM interop 呼叫時才會使用和處理傳址方式傳遞的參數。ParameterModifier is only used when calling through COM interop, and only parameters that are passed by reference are handled.

如果沒有完全相符,binder會嘗試強制轉型中指定的參數類型types,就可以選取 相符項目陣列。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. 如果binder無法選取相符項目,然後null會傳回。If the binder is unable to select a match, then null is returned.

下列BindingFlags篩選器旗標可以用來定義要包含在搜尋中的建構函式:The following BindingFlags filter flags can be used to define which constructors to include in the search:

  • 您必須指定BindingFlags.InstanceBindingFlags.Static以取得傳回值。You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.

  • 指定BindingFlags.Public来包含在搜尋中的公用建構函式。Specify BindingFlags.Public to include public constructors in the search.

  • 指定BindingFlags.NonPublic要在搜尋中包含非公用建構函式 (也就是私用、 內部和受保護建構函式)。Specify BindingFlags.NonPublic to include non-public constructors (that is, private, internal, and protected constructors) in the search.

如需詳細資訊,請參閱 System.Reflection.BindingFlagsSee System.Reflection.BindingFlags for more information.

這個方法會實作 GetConstructorThis method implements GetConstructor.

適用於

另請參閱