Contrary to the screenshot in the question, C# 8 is actually compatible with the .NET Framework. To use C# 8 with the .NET Framework, just set the language version to 8.0 in the .csproj file.
Most C# 8 features, including static local functions, using declarations, and switch expressions, work correctly in the target framework.
Asynchronous streams and indexes/ranges require new types not found in the .NET Framework. However, these features can be enabled using "polyfill" NuGet packages or custom code files.
Default interface members are not supported and will never be compatible with the .NET Framework due to required runtime changes in the CLR.
In Visual Studio 2019 16.3 and above, the language selection dropdown menu has been disabled and C# 8 must be explicitly enabled in the .csproj file.
While C# 8 is technically compatible with the .NET Framework, some features may have limited support or require additional workarounds. We recommend caution and thorough testing of any C# 8 code targeting the .NET Framework.
The above is the detailed content of Can C# 8 Be Used with the .NET Framework?. For more information, please follow other related articles on the PHP Chinese website!