我有一个泛型课,Foo<T>.在一个方法中Foo,我想得到类型为T的类实例,但我无法调用T.class.
使用它的首选方法是什么T.class?
我怎样才能做到这一点?
public class GenericClass<T>
{
public Type getMyType()
{
//How do I return the type of T?
}
}
Run Code Online (Sandbox Code Playgroud)
到目前为止我尝试的所有东西总是返回类型Object而不是使用的特定类型.