tags:

views:

251

answers:

1

I have a generic type:

MyType<T1, T2, T3>

and i want to do this:

typeof(MyType<,,>).MakeGenericType(new [] { null, null, string});

so i end up with:

MyType<,,string>

But, you can't pass null types into MakeGenericType (see: http://msdn.microsoft.com/en-us/library/system.type.makegenerictype.aspx).

How do I achieve this?

Thanks

+1  A: 

Ok I avoided it like this:

var args = typeof(MyType<,,>).GetGenericArguments();
args[2] = typeof(string);
typeof(MyType<,,>).MakeGenericType(args);
Andrew Bullock