You have to user reflection to obtain the result with Type.MakeGenericType. Assume Convert
method is static and in Temp
class:
class Temp
{
public static object Convert<T1, T2>()
{
//do stuff
}
}
Then you can call:
// assume code to get type1 and type2 dynamically
var type1 = GetGetType1();
var type2 = GetGetType2();
var method = typeof(Temp).GetMethod("Convert")
.MakeGenericMethod(type1, type2);
method.Invoke(null, null); //assume Convert is static method