Binder.SelectMethod(BindingFlags, MethodBase[], Type[], ParameterModifier[]) 方法


基于参数类型,从给定的方法集中选择一个方法。Selects a method from the given set of methods, based on the argument type.

 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



BindingFlags 值的按位组合。A bitwise combination of BindingFlags values.


用于匹配的候选方法集。The set of methods that are candidates for matching. 例如,当 Binder 使用 InvokeMember 对象时,此参数将指定反射已确定为可能匹配项的方法集,通常是因为它们有正确的成员名称。For example, when a Binder object is used by InvokeMember, this parameter specifies the set of methods that reflection has determined to be possible matches, typically because they have the correct member name. DefaultBinder 提供的默认实现会更改此数组的顺序。The default implementation provided by DefaultBinder changes the order of this array.


用于定位匹配方法的参数类型。The parameter types used to locate a matching method.


使绑定能够处理在其中修改了类型的参数签名的参数修饰符数组。An array of parameter modifiers that enable binding to work with parameter signatures in which the types have been modified.



如果找到,则为匹配的方法;否则为 nullThe matching method, if found; otherwise, null.


对于默认联编程序,match 包含多个与由 types 描述的参数类型良好匹配且匹配程序相同的方法。For the default binder, match contains multiple methods that are equally good matches for the parameter types described by types. 例如,types 中的数组包含一个用于 MyClassType 对象,并且 match 中的数组包含一个采用 MyClass 的基类的方法和一个采用 MyClass 实现的接口的方法。For example, the array in types contains a Type object for MyClass and the array in match contains a method that takes a base class of MyClass and a method that takes an interface that MyClass implements.

对于默认联编程序,matchnull 或一个空数组。For the default binder, match is null or an empty array.

- 或 --or- types 的元素从 Type 派生,但并不属于类型 RuntimeTypeAn element of types derives from Type, but is not of type RuntimeType.


null如果没有与条件匹配的方法,则此方法应返回。This method should return null if no method matches the criteria. 此方法控制中的和方法提供的选择 GetConstructor GetMethod TypeThis method controls the selection provided by the GetConstructor and GetMethod methods on Type.