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

另请参阅

适用于