Type.GetMethodImpl 方法

定義

多載

GetMethodImpl(String, Int32, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

在衍生類別中覆寫時,使用指定的繫結限制式和指定的呼叫慣例來搜尋指定的方法,其參數符合指定的泛型參數計數、引數型別及修飾元。

GetMethodImpl(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

在衍生類別中覆寫時,使用指定的繫結條件約束和指定的呼叫慣例搜尋指定的方法,而該方法的參數符合指定的引數類型和修飾詞。

GetMethodImpl(String, Int32, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

Source:
Type.cs
Source:
Type.cs
Source:
Type.cs

在衍生類別中覆寫時,使用指定的繫結限制式和指定的呼叫慣例來搜尋指定的方法,其參數符合指定的泛型參數計數、引數型別及修飾元。

protected:
 virtual System::Reflection::MethodInfo ^ GetMethodImpl(System::String ^ name, int genericParameterCount, System::Reflection::BindingFlags bindingAttr, System::Reflection::Binder ^ binder, System::Reflection::CallingConventions callConvention, cli::array <Type ^> ^ types, cli::array <System::Reflection::ParameterModifier> ^ modifiers);
protected virtual System.Reflection.MethodInfo? GetMethodImpl (string name, int genericParameterCount, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder? binder, System.Reflection.CallingConventions callConvention, Type[]? types, System.Reflection.ParameterModifier[]? modifiers);
protected virtual System.Reflection.MethodInfo GetMethodImpl (string name, int genericParameterCount, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention, Type[] types, System.Reflection.ParameterModifier[] modifiers);
abstract member GetMethodImpl : string * int * System.Reflection.BindingFlags * System.Reflection.Binder * System.Reflection.CallingConventions * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.MethodInfo
override this.GetMethodImpl : string * int * System.Reflection.BindingFlags * System.Reflection.Binder * System.Reflection.CallingConventions * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.MethodInfo
Protected Overridable Function GetMethodImpl (name As String, genericParameterCount As Integer, bindingAttr As BindingFlags, binder As Binder, callConvention As CallingConventions, types As Type(), modifiers As ParameterModifier()) As MethodInfo

參數

name
String

字串,包含要取得的方法名稱。

genericParameterCount
Int32

方法的泛型型別參數數目。

bindingAttr
BindingFlags

列舉值的位元組合,用來指定搜尋的執行方式。

-或-

要傳回 nullDefault

binder
Binder

定義一組屬性並啟用繫結的物件,可包含多載方法的選擇、引數類型的強制,以及透過反映的成員引動過程。

-或-

Null 參考 (在 Visual Basic 中為Nothing ),可使用 DefaultBinder

callConvention
CallingConventions

物件,其指定一組所要使用的規則,而這些規則是關於引數的順序和配置、如何傳遞傳回值、引數使用哪些暫存器以及哪一個處理程序清除堆疊。

types
Type[]

Type 物件的陣列,代表所要取得之方法的參數數目、順序和類型。

-或-

用以取得沒有參數的方法之 Type 類型的空陣列 (也就是,Type[] types = new Type[0])。

-或-

null. 如果 typesnull,則引數不相符。

modifiers
ParameterModifier[]

ParameterModifier 物件的陣列,代表在 types 陣列中與對應項目關聯的屬性。 預設的繫結器不會處理這個參數。

傳回

代表方法的物件,其符合指定的泛型參數計數、引數型別、修飾元、繫結限制式及呼叫慣例 (如果有的話);否則為 null

例外狀況

此方法必須在衍生類別中覆寫和呼叫。

適用於

GetMethodImpl(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

Source:
Type.cs
Source:
Type.cs
Source:
Type.cs

在衍生類別中覆寫時,使用指定的繫結條件約束和指定的呼叫慣例搜尋指定的方法,而該方法的參數符合指定的引數類型和修飾詞。

protected:
 abstract System::Reflection::MethodInfo ^ GetMethodImpl(System::String ^ name, 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.MethodInfo? GetMethodImpl (string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder? binder, System.Reflection.CallingConventions callConvention, Type[]? types, System.Reflection.ParameterModifier[]? modifiers);
protected abstract System.Reflection.MethodInfo GetMethodImpl (string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention, Type[] types, System.Reflection.ParameterModifier[] modifiers);
abstract member GetMethodImpl : string * System.Reflection.BindingFlags * System.Reflection.Binder * System.Reflection.CallingConventions * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.MethodInfo
Protected MustOverride Function GetMethodImpl (name As String, bindingAttr As BindingFlags, binder As Binder, callConvention As CallingConventions, types As Type(), modifiers As ParameterModifier()) As MethodInfo

參數

name
String

字串,包含要取得的方法名稱。

bindingAttr
BindingFlags

列舉值的位元組合,用來指定搜尋的執行方式。

-或-

要傳回 nullDefault

binder
Binder

定義一組屬性並啟用繫結的物件,可包含多載方法的選擇、引數類型的強制,以及透過反映的成員引動過程。

-或-

Null 參考 (在 Visual Basic 中為Nothing ),可使用 DefaultBinder

callConvention
CallingConventions

物件,其指定一組所要使用的規則,而這些規則是關於引數的順序和配置、如何傳遞傳回值、引數使用哪些暫存器以及哪一個處理程序清除堆疊。

types
Type[]

Type 物件的陣列,代表所要取得之方法的參數數目、順序和類型。

-或-

用以取得沒有參數的方法之 Type 類型的空陣列 (也就是,Type[] types = new Type[0])。

-或-

null. 如果 typesnull,則引數不相符。

modifiers
ParameterModifier[]

ParameterModifier 物件的陣列,代表在 types 陣列中與對應項目關聯的屬性。 預設的繫結器不會處理這個參數。

傳回

物件,代表符合指定之需求的方法 (如有找到);否則為 null

例外狀況

找到一個以上的方法,其具有指定名稱,且符合指定繫結條件約束。

namenull

types 是多維的。

-或-

modifiers 是多維的。

-或-

typesmodifiers 的長度不同。

備註

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

如果 typesnull,則引數不相符。

下列 BindingFlags 篩選旗標可用來定義要包含在搜尋中的方法:

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

  • 指定 BindingFlags.Public 以在搜尋中包含公用方法。

  • 指定 BindingFlags.NonPublic 在搜尋中包含非公用方法 (,也就是私用、內部和受保護的方法) 。

  • 指定要 BindingFlags.FlattenHierarchypublic 階層中包含和 protected 靜態成員; private 繼承類別中的靜態成員不包含在內。

下列 BindingFlags 修飾詞旗標可用來變更搜尋的運作方式:

  • BindingFlags.IgnoreCase 忽略的大小 name寫。

  • BindingFlags.DeclaredOnly 只搜尋 在上 Type宣告的方法,而不是只繼承的方法。

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

另請參閱

適用於