Skip to content

Commit 35805a1

Browse files
authored
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 6fc2120 commit 35805a1

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
@@ -360,12 +360,17 @@ The list of constraints given in a `where` clause can include any of the followi
360360
A primary constraint can be a class type, the ***reference type constraint*** `class`, the ***value type constraint*** `struct`, or the ***unmanaged type constraint*** `unmanaged`.
361361

362362
A secondary constraint can be a *type_parameter* or *interface_type*.
363+
363364
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.
364365

365366
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 ([§9.3.11](types.md#9311-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*.
366367

367368
> *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*
368369
370+
The token `unmanaged` is neither a keyword nor a contextual keyword. When it is encountered, it will either:
371+
- Bind to a type named `unmanaged`
372+
- Bind to no type, in which case, it is interpreted as the unmanaged type constraint.
373+
369374
The unmanaged type constraint specifies that a type argument used for the type parameter shall be a non-nullable unmanaged type.
370375

371376
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)