Module.GetMethod 方法

定義

傳回方法,具有指定準則。

多載

GetMethod(String)

傳回具有指定名稱的方法。

GetMethod(String, Type[])

傳回具有指定名稱及參數類型的方法。

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

傳回方法,該方法具有指定的名稱、繫結資訊、呼叫慣例和參數類型及修飾詞。

GetMethod(String)

傳回具有指定名稱的方法。

public:
 System::Reflection::MethodInfo ^ GetMethod(System::String ^ name);
public System.Reflection.MethodInfo? GetMethod (string name);
public System.Reflection.MethodInfo GetMethod (string name);
member this.GetMethod : string -> System.Reflection.MethodInfo
Public Function GetMethod (name As String) As MethodInfo

參數

name
String

方法名稱。

傳回

MethodInfo

具有指定名稱的 MethodInfo 物件,或者,如果方法不存在,則為 null

例外狀況

namenull

適用於

GetMethod(String, Type[])

傳回具有指定名稱及參數類型的方法。

public:
 System::Reflection::MethodInfo ^ GetMethod(System::String ^ name, cli::array <Type ^> ^ types);
public System.Reflection.MethodInfo? GetMethod (string name, Type[] types);
public System.Reflection.MethodInfo GetMethod (string name, Type[] types);
member this.GetMethod : string * Type[] -> System.Reflection.MethodInfo
Public Function GetMethod (name As String, types As Type()) As MethodInfo

參數

name
String

方法名稱。

types
Type[]

要搜尋的參數類型。

傳回

MethodInfo

符合指定準則的 MethodInfo 物件;若方法不存在,則為 null

例外狀況

namenulltypesnull;或 types (i) 為 null

適用於

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

傳回方法,該方法具有指定的名稱、繫結資訊、呼叫慣例和參數類型及修飾詞。

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

參數

name
String

方法名稱。

bindingAttr
BindingFlags

其中一個 BindingFlags 位元旗標,用來控制搜尋。

binder
Binder

該物件會實作 Binder,其中包含與此方法相關的屬性。

callConvention
CallingConventions

方法的呼叫慣例。

types
Type[]

要搜尋的參數類型。

modifiers
ParameterModifier[]

參數修飾詞的陣列,用來進行與參數簽章的繫結工作,其中該參數簽章的類別已修改。

傳回

MethodInfo

符合指定準則的 MethodInfo 物件;若方法不存在,則為 null

例外狀況

namenulltypesnull;或 types (i) 為 null

另請參閱

適用於