M_Cyjb_Reflection_MethodInfoUtil_GenericArgumentsInferences - CYJB/Cyjb GitHub Wiki
根据给定的方法实参类型数组推断泛型方法的泛型类型。
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# 编程指南) 获取更多信息。
异常 | 条件 |
---|---|
ArgumentNullException |
method 为 null 。 |
ArgumentNullException |
types 为 null 。 |
InvalidOperationException | 当前 MethodInfo 不表示泛型方法定义。 也就是说,IsGenericMethodDefinition 返回 false 。 |
MethodInfoUtil 类
GenericArgumentsInferences 重载
Cyjb.Reflection 命名空间