M_Cyjb_Reflection_MethodInfoUtil_GenericArgumentsInferences - CYJB/Cyjb GitHub Wiki

MethodInfoUtil.GenericArgumentsInferences 方法 (MethodBase, Type[])

根据给定的方法实参类型数组推断泛型方法的泛型类型。

Namespace: Cyjb.Reflection
Assembly: Cyjb (in Cyjb.dll) Version: 1.0.23+7750dd8e971297c5fa962a3bee37fb78f72793f6

语法

C#

public static Type[]? GenericArgumentsInferences(
	this MethodBase method,
	params Type[] types
)

参数

 

method
Type: System.Reflection.MethodBase
要推断泛型类型的泛型方法定义。
types
Type: System.Type[]
方法实参类型数组。

返回值

Type: Type[]
如果成功推断泛型方法的类型参数,则为推断结果;否则为 null

备注

在 Visual Basic 和 C# 中,这个方法可以当成为类型MethodBase的实例方法来调用。在采用实例方法语法调用这个方法时,请省略第一个参数。请参考 扩展方法 (Visual Basic)扩展方法 (C# 编程指南) 获取更多信息。

Exceptions

 

异常 条件
ArgumentNullException methodnull
ArgumentNullException typesnull
InvalidOperationException 当前 MethodInfo 不表示泛型方法定义。 也就是说,IsGenericMethodDefinition 返回 false

参见

Reference

MethodInfoUtil 类
GenericArgumentsInferences 重载
Cyjb.Reflection 命名空间

⚠️ **GitHub.com Fallback** ⚠️