What's the best way to instantiate a generic from its name?

前端 未结 3 1381

Assuming I have only the class name of a generic as a string in the form of \"MyCustomGenericCollection(of MyCustomObjectClass)\" and don\'t know the assembly it comes from,

3条回答
  •  时光取名叫无心
    2021-01-20 07:56

    The MSDN article How to: Examine and Instantiate Generic Types with Reflection describes how you can use Reflection to create an instance of a generic Type. Using that in conjunction with Marksus's sample should hopefully get you started.

提交回复
热议问题