new Constraint (C# Reference)
Updated: July 20, 2015
For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.
new constraint specifies that any type argument in a generic class declaration must have a public parameterless constructor. To use the new constraint, the type cannot be abstract.
new constraint to a type parameter when your generic class creates new instances of the type, as shown in the following example:
When you use the
new() constraint with other constraints, it must be specified last:
For more information, see Constraints on Type Parameters.
For more information, see the C# Language Specification. The language specification is the definitive source for C# syntax and usage.