Skip to content

Commit e8b3b8b

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

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

standard/classes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ The nullability of the type argument need not match the nullability of the type
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
445445
<!-- Remove in C# 9, when this is allowed -->
446-
The nullable type annotation, `?`, can’t be used on an unconstrained type argument.
446+
The nullable type annotation, `?`, can only be used on a type parameter that has 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)