How to enable C# 9.0-preview

后端 未结 3 455
太阳男子
太阳男子 2020-12-18 18:14

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#

3条回答
  •  有刺的猬
    2020-12-18 19:10

    As per October 2020,

    1. you can explicitly use the 9.0 language version in .csproj
    2. Using target framework as .net 5 implicitly uses C# 9 by default .

    The .csproj should be as such:

    
      
        Exe
        net5.0
      
    
    

    You can add 9.0 if you wish, but it should be optional.

    OutputType can be adapted, of course, and you'll need the .NET 5 SDK.

    See for instance this blog for more information.

提交回复
热议问题