With Visual Studio 2019 Preview (currently version 16.2.0 Preview 3.0) you can use C# 8.0 in .NET Core 3.0 projects. You only have to set the Language version to C# 8.0 (beta) in the Advanced Build Settings. Make sure you do this for 'All configurations' and 'Any CPU', see screenshot below.
This setting will add a LangVersion property to your .csproj file (line 6).
Core 2.2, .NET Framework and UWP projects
If you try to set the Language version property in a non .NET Core 3.0 project the dropdown doesn't show the C# 8.0 option.
You may think it is not possible to use C# 8.0 in these projects. Luckely you still can but you have to add the LangVersion property manually in the .csproj file (line 6).
The same also works in .NET Framework projects (ASP.NET, Windows Forms, WPF, Console, Class Library, etc) and UWP projects (line 5 in both screenshots below). You first have to Unload the project before you can Edit it. Reload the project when you are done. You can also edit it in an external text editor.
Unsupported C# 8.0 features
C# 8.0 comes with a lot of new features which are described in the What's new in C# 8.0 documentation. Unfortunately the Default interface members and Indices and ranges features are only supported in .NET Core 3.0 projects. Still there are enough great features to use.
Closure
This workaround is something Microsoft will fix in a new version of Visual Studio. I expect it will be released together with .NET Core 3.0 on the .NET Conf 2019 (online) event (September 23 — 25, 2019). C# 8.0 is now still in Beta, please don't use if in your production code. Have fun with the new features.
Fons
All postings/content on this blog are provided "AS IS" with no warranties, and confer no rights. All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer or sponsors. The content on this site is licensed under a Creative Commons Attribution By license.
Blog comments
Tudor
16-Jul-2019 1:34On job support
29-Aug-2019 8:17online job support
22-Oct-2019 1:44NuShrike
24-Nov-2020 8:50TAFF
05-Oct-2021 7:02TAFF
05-Oct-2021 7:03