In Visual Studio 16.2 (from preview 1) the property name is changed to Nullable
, which is simpler and aligns with the command line argument.
Add the following properties to your .csproj
file.
<PropertyGroup>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
If you're targeting netcoreapp3.0
or later, you don't need to specify a LangVersion
to enable nullable reference types.
For older Visual Studio versions:
- From 16.0 preview 2 to 16.1, set
NullableContextOptions
to enable
.
- In 16.0 preview 1, set
NullableReferenceTypes
to true
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…