Binder.SelectMethod 方法

定义

基于参数类型,从给定的方法集中选择一个方法。

public:
 abstract System::Reflection::MethodBase ^ SelectMethod(System::Reflection::BindingFlags bindingAttr, cli::array <System::Reflection::MethodBase ^> ^ match, cli::array <Type ^> ^ types, cli::array <System::Reflection::ParameterModifier> ^ modifiers);
public abstract System.Reflection.MethodBase? SelectMethod (System.Reflection.BindingFlags bindingAttr, System.Reflection.MethodBase[] match, Type[] types, System.Reflection.ParameterModifier[]? modifiers);
public abstract System.Reflection.MethodBase SelectMethod (System.Reflection.BindingFlags bindingAttr, System.Reflection.MethodBase[] match, Type[] types, System.Reflection.ParameterModifier[] modifiers);
abstract member SelectMethod : System.Reflection.BindingFlags * System.Reflection.MethodBase[] * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.MethodBase
Public MustOverride Function SelectMethod (bindingAttr As BindingFlags, match As MethodBase(), types As Type(), modifiers As ParameterModifier()) As MethodBase

参数

bindingAttr
BindingFlags

BindingFlags 值的按位组合。

match
MethodBase[]

用于匹配的候选方法集。 例如,当 Binder 使用 InvokeMember 对象时,此参数将指定反射已确定为可能匹配项的方法集,通常是因为它们有正确的成员名称。 由 DefaultBinder 提供的默认实现会更改此数组的顺序。

types
Type[]

用于定位匹配方法的参数类型。

modifiers
ParameterModifier[]

使绑定能够处理在其中修改了类型的参数签名的参数修饰符数组。

返回

MethodBase

如果找到,则为匹配的方法;否则为 null

例外

对于默认联编程序,match 包含多个与由 types 描述的参数类型良好匹配且匹配程序相同的方法。 例如,types 中的数组包含一个用于 MyClassType 对象,并且 match 中的数组包含一个采用 MyClass 的基类的方法和一个采用 MyClass 实现的接口的方法。

对于默认联编程序,matchnull 或一个空数组。

  • 或 - types 的元素从 Type 派生,但并不属于类型 RuntimeType

注解

如果没有与条件匹配的方法,则此方法应返回 null 。 此方法控制由 GetConstructor 选项和 GetMethod 方法提供的 Type选定内容。

适用于