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/types.md
+27-4Lines changed: 27 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -869,10 +869,13 @@ Every expression has one of three ***null state***s:
869
869
870
870
The ***default null state*** of an expression is determined by its type, and the state of the annotations flag when it is declared:
871
871
872
-
- The default null state of a nullable reference type is:
873
-
- Maybe null when its declaration is in text where the annotations flag is enabled.
874
-
- Not null when its declaration is in text where the annotations flag is disabled.
875
-
- The default null state of a non-nullable reference type is not null.
872
+
- The default state of the `null` literal ([§6.4.5.7](lexical-structure.md#6457-the-null-literal)) ismaybenull.
873
+
- Thedefaultstateofadefaultvalueexpression ([§12.8.21](expressions.md#12821-default-value-expressions)) isnotnull when the type is a non-nullable value type, otherwise maybe null.
> *Note:*The*maybedefault*stateisusedwithunconstrainedtypeparameters when the type is a non-nullable type, such as `string` and the expression `default(T)` is the null value. Because null is not in the domain for the non-nullable type, the state is maybe default. *end note*
878
881
@@ -1168,4 +1171,24 @@ A compiler may issue a warning when nullability differs in either direction in t
0 commit comments