7
我想创建一个强类型列表并在运行时决定类型。这是我的code.I认为它应该工作,但它不会:)确定运行时类型并将其应用于泛型 - 我该怎么做?
Type elementType = Type.GetType(parts[0].Trim(),false,true);
var elementsBeingSet = new List<elementType>();
请问您有什么ideat如何创建一个强类型的列表,它的类型,我会在运行时决定?
重复:这里有其它版本:
- Is it impossible to use Generics dynamically?
- Declare a generic type instance dynamically
- Calling generic method with a type argument known only at execution time
对不起,我找不到其他人。 – 2008-11-28 17:47:50