Skip to content

Commit a388043

Browse files
RexJaeschkeBillWagner
authored andcommitted
Tweak the recently added description of unmanaged constraint
Describe what happens when a type called `unmanaged` exists in the scope of an unmanaged constraint.
1 parent 4446f0f commit a388043

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

standard/classes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,12 +416,17 @@ The list of constraints given in a `where` clause can include any of the followi
416416
A primary constraint can be a class type, the ***reference type constraint*** `class`, the ***value type constraint*** `struct`, or the ***unmanaged type constraint*** `unmanaged`.
417417

418418
A secondary constraint can be a *type_parameter* or *interface_type*.
419+
419420
The reference type constraint specifies that a type argument used for the type parameter shall be a reference type. All class types, interface types, delegate types, array types, and type parameters known to be a reference type (as defined below) satisfy this constraint.
420421

421422
The value type constraint specifies that a type argument used for the type parameter shall be a non-nullable value type. All non-nullable struct types, enum types, and type parameters having the value type constraint satisfy this constraint. Note that although classified as a value type, a nullable value type ([§8.3.11](types.md#8311-nullable-value-types)) does not satisfy the value type constraint. A type parameter having the value type constraint shall not also have the *constructor_constraint*, although it may be used as a type argument for another type parameter with a *constructor_constraint*.
422423

423424
> *Note*: The `System.Nullable<T>` type specifies the non-nullable value type constraint for `T`. Thus, recursively constructed types of the forms `T??` and `Nullable<Nullable<T>>` are prohibited. *end note*
424425
426+
The token `unmanaged` is neither a keyword nor a contextual keyword. When it is encountered, it will either:
427+
- Bind to a type named `unmanaged`
428+
- Bind to no type, in which case, it is interpreted as the unmanaged type constraint.
429+
425430
The unmanaged type constraint specifies that a type argument used for the type parameter shall be a non-nullable unmanaged type.
426431

427432
Pointer types are never allowed to be type arguments and are not considered to satisfy either the `reference` type or `value` type constraints.

0 commit comments

Comments
 (0)