I would like to get type from generic type fullname like that :
var myType = Type.GetType(\"MyProject.MyGenericType`1[[MyProject.MySimpleType, MyProject, Ver
Try this:
var myType = Type.GetType("MyProject.MyGenericType`1, MyProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]");
Then use MakeGenericType()
:
var finalType = myType.MakeGenericType(Type.GetType("MyProject.MySimpleType"));
Alternatively, if the open generic type can be determined at compile type, you can simply use the typeof
operator with <>
:
var myType = typeof(MyProject.MyGenericType<>);
var finalType = myType.MakeGenericType(typeof(MyProject.MySimpleType));
See MSDN