C# generic methods, type parameters in new() constructor constraint

后端 未结 3 994
一整个雨季
一整个雨季 2020-12-01 10:44

Is there a way to create a Generic Method that uses the new() constructor constraint to require classes with constructors of specific types?

For

3条回答
  •  情书的邮戳
    2020-12-01 11:22

    No, it is not possible in C# to constrain the generic type to have a constructor of a specific signature. Only the parameterless constructor is supported by new().

提交回复
热议问题