Reputation: 17530
public MyType<T,T1,T2>
{
}
I need to do a Expression.New(typeof(MyType<,,>))
At compile time I do not know T,T1,T2. The expression new is inside a method
Expression CreateExpression(Type t, Type t1)
{
Type t2 = Lookup(t,t1);
return Expression.New(typeof(MyType<t,t1,t2>), ...constructorparams...);
}
I made the example as simple as possible for the sake of the question. Anyone know a way to do this?
Upvotes: 1
Views: 647
Reputation: 17530
I found out I can do this:
var t = typeof(C1EntitySet<,,>);
t.MakeGenericType(new Type[]{t,t1,t2});
Upvotes: 1