Skip to content

Commit e7d97fa

Browse files
committed
Not every constrained type parameter may be annotated
1 parent f4d9ffe commit e7d97fa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

standard/classes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ The nullability of the type argument need not match the nullability of the type
442442

443443
> *Note*: To specify that a type argument is a nullable reference type, don’t add the nullable type annotation as a constraint (use `T : class` or `T : BaseClass`), but use `T?` throughout the generic declaration to indicate the corresponding nullable reference type for the type argument. *end note*
444444
445-
<!-- Remove in C# 9, when this is allowed -->
446-
The nullable type annotation, `?`, can’t be used on an unconstrained type argument.
445+
<!-- Remove in C# 9, when `?` is allowed on any type parameter. -->
446+
The nullable type annotation, `?`, can only be used on a type parameter that has the value type constraint, the reference type constraint, or a class type constraint.
447447

448448
For a type parameter `T` when the type argument is a nullable reference type `C?`, instances of `T?` are interpreted as `C?`, not `C??`.
449449

0 commit comments

Comments
 (0)