1
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?

1 Answer 1

1

I found out I can do this:

    var t = typeof(C1EntitySet<,,>);
    t.MakeGenericType(new Type[]{t,t1,t2});
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.