Export (0) Print
Expand All
Expand Minimize
0 out of 5 rated this helpful - Rate this topic

'New' cannot be used on a type parameter that does not have a 'New' constraint

A declaration statement uses a New (Visual Basic) clause specifying a type parameter as the type to be created, and the type parameter is declared without a New constraint.

A constraint on a type parameter imposes a requirement on any type argument passed to that type parameter when the generic type is created. The New constraint specifies that the type argument must expose a parameterless constructor that the creating code can access. This is what allows a New clause in a declaration statement to create an instance of that type.

Error ID: BC32046

To correct this error

  • If you can require the type argument to expose an accessible parameterless constructor, add the New constraint to the declaration of the type parameter.

  • If you cannot require the type argument to expose an accessible parameterless constructor, remove the New clause from the declaration statement. You cannot guarantee that any type argument passed to that type parameter permits creation of an instance.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.