You can not.
General parameters are used and applied by the compiler, and Typeis part of Reflections, which are designed to work with type information at run time. Therefore, you simply cannot determine what type of compiler should be used if you only have one System.Type.
However, you can do the opposite:
public void Foo<T>()
{
Type t = typeof(T);
}
So, if you really don't need to use Typeas a parameter, you can do the following:
Foo<FooParam> MakeFoo<FooParam>()
{
return new Foo<FooParam>();
}
source
share