myermian
myermian

Reputation: 32525

Dynamically creating a Type

I have the following: typeof(Action<User, Int32>) which I need to be able to create dynamically...

I have both of the types I need stored as a Type object.

Type type1 = ...; // MyNamespace.BusinessObjects.User
Type type2 = ...; // System.Int32

// I need it to be Action<MyNamespace.BusinessObjects.User, System.Int32>
Type action = ? ;

Not sure what to do here to get this going.

Upvotes: 3

Views: 75

Answers (1)

BFree
BFree

Reputation: 103770

I think this should work:

var actionType = typeof(Action<,>).MakeGenericType(type1,type2);

Upvotes: 5

Related Questions