string? nullableString
Nullable value types are understandable why they are needed. But why reference types need nullable?
string? nullableString
Nullable value types are understandable why they are needed. But why reference types need nullable?
Nullable references types were added to the language to decrease likelyhood of null reference exception via static code analysis by compiler:
- Improved static flow analysis that determines if a variable may be null before dereferencing it.
- Attributes that annotate APIs so that the flow analysis determines null-state.
- Variable annotations that developers use to explicitly declare the intended null-state for a variable.
Nullable reference types is an opttional feature which can be enabled/disabled for example on file or project level.