问题:
The title is kind of obscure.标题有点晦涩。 What I want to know is if this is possible:我想知道的是这是否可能:
string typeName = <read type name from somwhere>;
Type myType = Type.GetType(typeName);
MyGenericClass<myType> myGenericClass = new MyGenericClass<myType>();
Obviously, MyGenericClass is described as:显然,MyGenericClass 被描述为:
public class MyGenericClass<T>
Right now, the compiler complains that 'The type or namespace 'myType' could not be found." There has got to be a way to do this.现在,编译器抱怨“找不到类型或命名空间‘myType’。”必须有办法做到这一点。
解决方案:
参考一: https://en.stackoom.com/question/17EB参考二: https://stackoom.com/question/17EB