In C#, how to instantiate a passed generic type inside a method?

前端 未结 8 1075
逝去的感伤
逝去的感伤 2020-11-30 21:19

How can I instantiate the type T inside my InstantiateType method below?

I\'m getting the error: \'T\' is a \'type parameter\' but is u

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 21:36

    you want new T(), but you'll also need to add , new() to the where spec for the factory method

提交回复
热议问题