Type.GetMethodImpl 方法

定义

重载

GetMethodImpl(String, Int32, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

当在派生类中重写时,使用指定的绑定约束和指定的调用约定搜索其参数与指定泛型参数计数、参数类型和修饰符匹配的指定方法。

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

当在派生类中重写时,使用指定的绑定约束和指定的调用约定搜索其参数与指定的自变量类型和修饰符匹配的指定方法。

GetMethodImpl(String, Int32, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

当在派生类中重写时,使用指定的绑定约束和指定的调用约定搜索其参数与指定泛型参数计数、参数类型和修饰符匹配的指定方法。

protected:
 virtual System::Reflection::MethodInfo ^ GetMethodImpl(System::String ^ name, int genericParameterCount, System::Reflection::BindingFlags bindingAttr, System::Reflection::Binder ^ binder, System::Reflection::CallingConventions callConvention, cli::array <Type ^> ^ types, cli::array <System::Reflection::ParameterModifier> ^ modifiers);
protected virtual System.Reflection.MethodInfo? GetMethodImpl (string name, int genericParameterCount, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder? binder, System.Reflection.CallingConventions callConvention, Type[]? types, System.Reflection.ParameterModifier[]? modifiers);
protected virtual System.Reflection.MethodInfo GetMethodImpl (string name, int genericParameterCount, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention, Type[] types, System.Reflection.ParameterModifier[] modifiers);
abstract member GetMethodImpl : string * int * System.Reflection.BindingFlags * System.Reflection.Binder * System.Reflection.CallingConventions * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.MethodInfo
override this.GetMethodImpl : string * int * System.Reflection.BindingFlags * System.Reflection.Binder * System.Reflection.CallingConventions * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.MethodInfo
Protected Overridable Function GetMethodImpl (name As String, genericParameterCount As Integer, bindingAttr As BindingFlags, binder As Binder, callConvention As CallingConventions, types As Type(), modifiers As ParameterModifier()) As MethodInfo

参数

name
String

包含要获取的方法名称的字符串。

genericParameterCount
Int32

方法的泛型类型参数的数目。

bindingAttr
BindingFlags

枚举值的按位组合,这些值指定如何进行搜索。

若为 Default,则返回 null

binder
Binder

一个对象,该对象定义一组属性并启用绑定,而绑定可能涉及选择重载方法、强制参数类型和通过反射调用成员。

要使用 Nothing 的空引用(在 Visual Basic 中为 DefaultBinder)。

callConvention
CallingConventions

该对象,用于指定要使用的一套规则,这些规则涉及自变量的顺序和布局、传递返回值的方式、用于自变量的寄存器以及哪个进程清理堆栈。

types
Type[]

表示此方法要获取的参数的个数、顺序和类型的 Type 对象数组。

一个类型为 Type (即 Type[] types = new Type[0])的空数组,用于获取一个不带参数的方法。

null. 如果 typesnull,则自变量不匹配。

modifiers
ParameterModifier[]

ParameterModifier 对象的数组,表示与 types 数组中的相应元素关联的特性。 默认的联编程序不处理此参数。

返回

表示与指定泛型参数计数、参数类型、修饰符、绑定约束及调用约定匹配的方法的对象(如果找到的话);否则为 null

例外

需要在派生类中重写并调用方法。

适用于

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

当在派生类中重写时,使用指定的绑定约束和指定的调用约定搜索其参数与指定的自变量类型和修饰符匹配的指定方法。

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

参数

name
String

包含要获取的方法名称的字符串。

bindingAttr
BindingFlags

枚举值的按位组合,这些值指定如何进行搜索。

若为 Default,则返回 null

binder
Binder

一个对象,该对象定义一组属性并启用绑定,而绑定可能涉及选择重载方法、强制参数类型和通过反射调用成员。

要使用 Nothing 的空引用(在 Visual Basic 中为 DefaultBinder)。

callConvention
CallingConventions

该对象,用于指定要使用的一套规则,这些规则涉及自变量的顺序和布局、传递返回值的方式、用于自变量的寄存器以及哪个进程清理堆栈。

types
Type[]

表示此方法要获取的参数的个数、顺序和类型的 Type 对象数组。

一个类型为 Type (即 Type[] types = new Type[0])的空数组,用于获取一个不带参数的方法。

null. 如果 typesnull,则自变量不匹配。

modifiers
ParameterModifier[]

ParameterModifier 对象的数组,表示与 types 数组中的相应元素关联的特性。 默认的联编程序不处理此参数。

返回

表示符合指定要求的方法的对象(如果找到的话);否则为 null

例外

找到多个具有指定名称且与指定绑定约束匹配的方法。

namenull

types 是多维的。

modifiers 是多维的。

typesmodifiers 的长度不相同。

注解

尽管默认绑定器不处理 ParameterModifier (modifiers 参数) ,但可以使用抽象 System.Reflection.Binder 类编写处理 的 modifiers自定义绑定程序。 ParameterModifier 仅在通过 COM 互操作调用时才使用,并且仅处理由引用传递的参数。

如果 typesnull,则自变量不匹配。

以下 BindingFlags 筛选器标志可用于定义要在搜索中包括的方法:

  • 必须指定 BindingFlags.InstanceBindingFlags.Static 才能获得回报。

  • 指定 BindingFlags.Public 以在搜索中包含公共方法。

  • 指定 BindingFlags.NonPublic 以包括非公共方法 (,即搜索中) 私有方法、内部方法和保护方法。

  • 指定要 BindingFlags.FlattenHierarchy 在层次结构中包括 publicprotected 静态成员; private 继承类中的静态成员不包括在层次结构中。

以下 BindingFlags 修饰符标志可用于更改搜索的工作方式:

  • BindingFlags.IgnoreCase 以忽略 的 name大小写。

  • BindingFlags.DeclaredOnly 如果只搜索 上 Type声明的方法,则搜索只是继承的方法。

有关更多信息,请参见System.Reflection.BindingFlags

另请参阅

适用于