You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: standard/classes.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -434,6 +434,7 @@ primary_constraint
434
434
|'struct'
435
435
|'notnull'
436
436
|'unmanaged'
437
+
|'default'
437
438
;
438
439
439
440
secondary_constraint
@@ -454,7 +455,9 @@ Each *type_parameter_constraints_clause* consists of the token `where`, followed
454
455
455
456
The list of constraints given in a `where` clause can include any of the following components, in this order: a single primary constraint, one or more secondary constraints, and the constructor constraint, `new()`.
456
457
457
-
A primary constraint can be a class type, the ***reference type constraint***`class`, the ***value type constraint***`struct`, the ***not null constraint***`notnull` or the ***unmanaged type constraint***`unmanaged`. The class type and the reference type constraint can include the *nullable_type_annotation*.
458
+
A primary constraint can be a class type, the ***reference type constraint***`class`, the ***value type constraint***`struct`, the ***not null constraint***`notnull`, the ***unmanaged type constraint***`unmanaged`, or `default`. The class type and the reference type constraint can include the *nullable_type_annotation*.
459
+
460
+
It is a compile-time error to use a `default` constraint other than on a method override or explicit implementation. It is a compile-time error to use a `default` constraint when the corresponding type parameter in the overridden or interface method is constrained to a reference type or value type.
458
461
459
462
A secondary constraint can be an *interface_type* or *type_parameter*, optionally followed by a *nullable_type_annotation*. The presence of the *nullable_type_annotation* indicates that the type argument is allowed to be the nullable reference type that corresponds to a non-nullable reference type that satisfies the constraint.
460
463
@@ -559,6 +562,8 @@ The unmanaged type constraint specifies that a type argument used for the type p
Ifaconstraintisaclasstype, aninterfacetype, or a type parameter, that type specifies a minimal “base type” that every type argument used for that type parameter shall support. Whenever a constructed type or generic method is used, the type argument is checked against the constraints on the type parameter at compile-time. The type argument supplied shall satisfy the conditions described in [§8.4.5](types.md#845-satisfying-constraints).
0 commit comments