Make sure you are ready for it! Today when I started to try out some of the features of C#9.0 I was immediately blocked by an error in Visual Studio 2019 (which I have been working with for a while now).

The new record keyword gave me an error :

I figured this would be one of the most common errors encountered by people getting started on C#9.0 and so it was worth posting it.

The fix for this is simple. We need to change the .NET core version since these support different C# versions. Depending on the >NET version used by the project the appropriate C# version will be used. To see the target framework used by the project Go to “Properties” of the project.

And then select the Application section on right. 

The default C# versions selected based on the Target framework are as below. Please refer to original source here.

That’s it! Once we select the target framework as .NET5.0, I could test out all the features of C#9.0.



Source link

Write A Comment