Does C# 8 Support The. Net Framework?
In Visual Studio 2019 Advanced Build Settings, C# 8 Does Not Appear to Be Available for A. Net Framework Project, Only (As in the Picture Below) for A. Net...
In Visual Studio 2019 Advanced Build settings, C# 8 does not appear to be available for a .NET Framework project, only (as in the picture below) for a .NET Core 3.0 project:
Does C# 8 support the .NET Framework?
3 Answers
Yes, C# 8 can be used with the .NET Framework and other targets older than .NET Core 3.0/.NET Standard 2.1 in Visual Studio 2019 (or older versions of Visual Studio if you install a NuGet package).
The only thing required is to set language version to 8.0 in the csproj file. You can also do this in Directory.Build.props to apply it to all projects in your solution. Read below for how to do this in Visual Studio 2019, version 16.3 and newer.
Most - but not all - features are available whichever framework is targeted.
Must Read
Features that work
The following features are syntax changes only; they work regardless of framework:
- Static local functions
- Using declarations
- Null-coalescing assignment
- Readonly members
- Disposable ref structs
- Positional patterns
- Tuple patterns
- Switch expressions
- Nullable reference types are also supported, but the new nullable attributes required to design the more complex nullable use cases are not. I cover this in more detail further down in the "gory details" section.