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/expressions.md
+13-5Lines changed: 13 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7027,11 +7027,11 @@ constant_expression
7027
7027
;
7028
7028
```
7029
7029
7030
-
A constant expression shall either have the value `null` or one of the following types:
7030
+
A constant expression may be either a value type or a reference type. If a constant expression has a value type, that type shall be one of the following: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `nint`, `nuint`, `long`, `ulong`, `char`, `float`, `double`, `decimal`, `bool,` or any enumeration type. If a constant expression has a reference type, the expression shall:
- a default value expression ([§12.8.21](expressions.md#12821-default-value-expressions)) for a reference type.
7032
+
-have a value of type`string`;
7033
+
-have a value of `null`; or
7034
+
-be a default value expression ([§12.8.21](expressions.md#12821-default-value-expressions)) of reference type.
7035
7035
7036
7036
A *constant_expression* of type `nint` shall have a value in the range \[`int.MinValue`,`int.MaxValue`\]. A *constant_expression* of type `nuint` shall have a value in the range \[`uint.MinValue`,`uint.MaxValue`\].
7037
7037
@@ -7083,7 +7083,15 @@ Whenever an expression fulfills the requirements listed above, the expression is
Copy file name to clipboardExpand all lines: standard/types.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -217,6 +217,8 @@ nullable_value_type
217
217
;
218
218
```
219
219
220
+
Because the names `nint` and `nuint` are not keywords there is syntactic ambiguity between recognising them as a *type_name* or a *value_type*. In context if type resolution (§7.8.1) on either of these names succeeds then that name shall be recognised as a *type_name*; otherwise it shall be recognised as a *value_type*.
221
+
220
222
Unlike a variable of a reference type, a variable of a value type can contain the value `null` only if the value type is a nullable value type ([§8.3.12](types.md#8312-nullable-value-types)). For every non-nullable value type there is a corresponding nullable value type denoting the same set of values plus the value `null`.
221
223
222
224
Assignment to a variable of a value type creates a *copy* of the value being assigned. This differs from assignment to a variable of a reference type, which copies the reference but not the object identified by the reference.
0 commit comments