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
@@ -7168,11 +7168,11 @@ constant_expression
7168
7168
;
7169
7169
```
7170
7170
7171
-
A constant expression shall either have the value `null` or one of the following types:
7171
+
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.
7173
+
-have a value of type`string`;
7174
+
-have a value of `null`; or
7175
+
-be a default value expression ([§12.8.21](expressions.md#12821-default-value-expressions)) of reference type.
7176
7176
7177
7177
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`\].
7178
7178
@@ -7224,7 +7224,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
@@ -222,6 +222,8 @@ nullable_value_type
222
222
;
223
223
```
224
224
225
+
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*.
226
+
225
227
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`.
226
228
227
229
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