Type.GetMethodImpl Type.GetMethodImpl Type.GetMethodImpl Method

定義

多載

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

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

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

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

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

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);
abstract member GetMethodImpl : string * System.Reflection.BindingFlags * System.Reflection.Binder * System.Reflection.CallingConventions * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.MethodInfo

參數

name
String String String

字串,包含要取得的方法名稱。The string containing the name of the method to get.

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 what process cleans up the stack.

types
Type[]

Type 物件的陣列,代表所要取得之方法的參數數目、順序和類型。An array of Type objects representing the number, order, and type of the parameters for the method 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 method that takes no parameters.

-或--or- null.null. 如果 typesnull,則引數不相符。If types is null, arguments are not matched.

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.

傳回

物件,代表符合指定之需求的方法 (如有找到);否則為 nullAn object representing the method that matches the specified requirements, if found; otherwise, null.

例外狀況

找到一個以上的方法,其具有指定名稱,且符合指定繫結條件約束。More than one method is found with the specified name and matching the specified binding constraints.

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抽象類別來撰寫執行處理modifiers的自訂系結器。Although 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.

如果 typesnull,則引數不相符。If types is null, arguments are not matched.

下列BindingFlags篩選旗標可以用來定義要包含在搜尋中的方法:The following BindingFlags filter flags can be used to define which methods 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 methods in the search.

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

  • 指定BindingFlags.FlattenHierarchy在階層publicprotected包含和靜態成員;private不包含繼承類別中的靜態成員。Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.

下列BindingFlags的修飾詞旗標可以用來變更搜尋的運作方式:The following BindingFlags modifier flags can be used to change how the search works:

  • BindingFlags.IgnoreCase忽略的大小寫nameBindingFlags.IgnoreCase to ignore the case of name.

  • BindingFlags.DeclaredOnly表示只搜尋在上Type宣告的方法, 而不是單純繼承的方法。BindingFlags.DeclaredOnly to search only the methods declared on the Type, not methods that were simply inherited.

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

另請參閱

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

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

參數

genericParameterCount
Int32 Int32 Int32
types
Type[]
modifiers
ParameterModifier[]

傳回

適用於