Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable C# 9.0-preview

Tags:

c#

.net-5

c#-9.0

I have downloaded and installed v5.0.0-preview.5. My project is targeting net5.0 but C# 9.0 is not working. How can I enable C# 9.0?

like image 812
Jerzy Grzelec Avatar asked Jun 15 '20 23:06

Jerzy Grzelec


People also ask

How do I enable C drive?

I would suggest you to enable the built-in administrator user account then give full permission for the “C:” drive and check how it works. Refer to the link “Enable / Disable the Local (Hidden, Built-In) Administrator Account in Windows 7” to know how to enable Built-in administrator user account.

How do I get C$ share on Windows 10?

Open computer management. Click Shared Folders. Select Shares. Make sure C$ is there.


1 Answers

As of October 2020:

Please see @Pac0's answer here: https://stackoverflow.com/a/64386529/159145

As of June 2020:

According to this page in the documentation you need to edit your *.csproj to set the <LangVersion> to preview.

Also mentioned in the blog-post about the preview-release, but not the above documentation page, is that you need to update your project's targetFramework property too to net5.0 (this is because the C# design team decided to restrict entire C# language versions to minimum BCL versions, unlike previously where you could use C# 7 with even .NET Framework 2.0 provided you reimplemented your own missing BCL types like ValueTuple and ExtensionAttribute).

So your *.csproj file should look like this:

<Project>  <PropertyGroup>    <LangVersion>preview</LangVersion>    <TargetFramework>net5.0</TargetFramework>  </PropertyGroup> </Project> 
like image 71
Dai Avatar answered Sep 29 '22 02:09

Dai