草庐IT

c# - 使用反射选择正确的通用方法

我想通过反射选择正确的通用方法,然后调用它。通常这很容易。例如varmethod=typeof(MyType).GetMethod("TheMethod");vartypedMethod=method.MakeGenericMethod(theTypeToInstantiate);然而,当该方法有不同的通用重载时,问题就开始了。例如System.Linq.Queryable-class中的静态方法。“Where”方法有两种定义staticIQueryableWhere(thisIQueryablesource,Expression>predicate)staticIQueryableW

c# - 使用反射选择正确的通用方法

我想通过反射选择正确的通用方法,然后调用它。通常这很容易。例如varmethod=typeof(MyType).GetMethod("TheMethod");vartypedMethod=method.MakeGenericMethod(theTypeToInstantiate);然而,当该方法有不同的通用重载时,问题就开始了。例如System.Linq.Queryable-class中的静态方法。“Where”方法有两种定义staticIQueryableWhere(thisIQueryablesource,Expression>predicate)staticIQueryableW