IReflect.GetMethod 方法

定義

擷取 MethodInfo 物件,對應至指定的方法。Retrieves a MethodInfo object that corresponds to a specified method.

多載

GetMethod(String, BindingFlags)

擷取 MethodInfo 物件,對應至所指定搜尋條件約束下的指定方法。Retrieves a MethodInfo object that corresponds to a specified method under specified search constraints.

GetMethod(String, BindingFlags, Binder, Type[], ParameterModifier[])

使用 MethodInfo 陣列從多載方法中選擇,擷取對應於指定方法的 Type 物件。Retrieves a MethodInfo object corresponding to a specified method, using a Type array to choose from among overloaded methods.

GetMethod(String, BindingFlags)

擷取 MethodInfo 物件,對應至所指定搜尋條件約束下的指定方法。Retrieves a MethodInfo object that corresponds to a specified method under specified search constraints.

public:
 System::Reflection::MethodInfo ^ GetMethod(System::String ^ name, System::Reflection::BindingFlags bindingAttr);
public System.Reflection.MethodInfo GetMethod (string name, System.Reflection.BindingFlags bindingAttr);
abstract member GetMethod : string * System.Reflection.BindingFlags -> System.Reflection.MethodInfo
Public Function GetMethod (name As String, bindingAttr As BindingFlags) As MethodInfo

參數

name
String

要尋找的成員名稱。The name of the member to find.

bindingAttr
BindingFlags

繫結屬性,用來控制搜尋。The binding attributes used to control the search.

傳回

MethodInfo 物件,包含方法資訊,並且符合是根據 bindingAttr 中所指定的方法名稱和搜尋條件約束。A MethodInfo object containing the method information, with the match being based on the method name and search constraints specified in bindingAttr.

例外狀況

物件會使用相同名稱,實作多重方法。The object implements multiple methods with the same name.

另請參閱

GetMethod(String, BindingFlags, Binder, Type[], ParameterModifier[])

使用 MethodInfo 陣列從多載方法中選擇,擷取對應於指定方法的 Type 物件。Retrieves a MethodInfo object corresponding to a specified method, using a Type array to choose from among overloaded methods.

public:
 System::Reflection::MethodInfo ^ GetMethod(System::String ^ name, System::Reflection::BindingFlags bindingAttr, System::Reflection::Binder ^ binder, cli::array <Type ^> ^ types, cli::array <System::Reflection::ParameterModifier> ^ modifiers);
public System.Reflection.MethodInfo GetMethod (string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, Type[] types, System.Reflection.ParameterModifier[] modifiers);
abstract member GetMethod : string * System.Reflection.BindingFlags * System.Reflection.Binder * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.MethodInfo

參數

name
String

要尋找的成員名稱。The name of the member to find.

bindingAttr
BindingFlags

繫結屬性,用來控制搜尋。The binding attributes used to control the search.

binder
Binder

該物件會實作 Binder,其中包含與此方法相關的屬性。An object that implements Binder, containing properties related to this method.

types
Type[]

陣列,用來在多載方法中選擇。An array used to choose among overloaded methods.

modifiers
ParameterModifier[]

參數修飾詞的陣列,用來進行與參數簽章的繫結工作,其中該參數簽章的類別已修改。An array of parameter modifiers used to make binding work with parameter signatures in which the types have been modified.

傳回

要求方法,符合所有指定參數。The requested method that matches all the specified parameters.

例外狀況

物件會使用相同名稱,實作多重方法。The object implements multiple methods with the same name.

備註

傳回值是根據方法名稱、 BindingFlags列舉成員、 binder參數所指定的類型轉換種類、多載, 以及ParameterInfo描述方法簽章的。The return value is a match based on the method name, BindingFlags enum member, the kind of type conversion specified by the binder parameter, the overload, and the ParameterInfo that describes the signature of the method.

另請參閱

適用於