IReflect.GetMethod Method

Definition

检索与指定方法对应的 MethodInfo 对象。Retrieves a MethodInfo object that corresponds to a specified method.

Overloads

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

Parameters

name
String

要查找的成员的名称。The name of the member to find.

bindingAttr
BindingFlags

用于控制搜索的绑定属性。The binding attributes used to control the search.

Returns

MethodInfo

包含方法信息的 MethodInfo 对象,匹配基于方法名和 bindingAttr 中指定的搜索约束。A MethodInfo object containing the method information, with the match being based on the method name and search constraints specified in bindingAttr.

Exceptions

该对象实现同名的多个方法。The object implements multiple methods with the same name.

See also

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
Public Function GetMethod (name As String, bindingAttr As BindingFlags, binder As Binder, types As Type(), modifiers As ParameterModifier()) As MethodInfo

Parameters

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.

Returns

MethodInfo

匹配所有指定参数的请求的方法。The requested method that matches all the specified parameters.

Exceptions

该对象实现同名的多个方法。The object implements multiple methods with the same name.

Remarks

返回值是一个匹配项,它基于方法名称、BindingFlags 枚举成员、binder 参数指定的类型转换类型、重载,以及描述方法签名的 ParameterInfoThe 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.

See also

Applies to