您不能直接这样做。泛型的目的是提供 编译时
类型安全性,使您在编译时知道您感兴趣的类型,并且可以使用该类型的实例。在您的情况下,您仅知道,
Type因此您无法进行任何编译时检查,以确保您拥有的任何对象都是该类型的实例。
您需要通过反射来调用该方法-类似于:
// Get the generic type definitionMethodInfo method = typeof(Session).GetMethod("Linq",BindingFlags.Public | BindingFlags.Static);// Build a method with the specific type argument you're interested inmethod = method.MakeGenericMethod(typeOne);// The "null" is because it's a static methodmethod.Invoke(null, arguments);如果你需要使用这种类型很多,你可能会发现更方便地编写需要调用哪些其他任何泛型方法你自己的泛型方法,然后调用 你 用反射法。



