How to Download C# 9.0 , Install and Try ?

Microsoft had released the preview version of .NET 5 some time back which comes with C# 9 Preview too. While it is still in preview , i am actually very excited to download C# 9.0 and try out the new features in C# 9 before it makes in to the official release (release candidate).

To download C# 9 and install is basically the same as installing .NET Preview 5.

How to Download , Install and Try C# 9 Preview ?

  • Ensure that you are running Visual Studio 2019 version 16.7 and higher. You can download them from Visual Studio download center. You can alternatively install and try Visual Studio Preview.
  • If you already have Visual Studio 16.7 or higher installed , you could simply download the latest .NET 5 Preview SDK from Microsoft portal.
  • Launch Visual Visual Studio and navigate to Tools -> Options and then select “Preview Features” and check the box “Use Preview of the .NET Core SDK” and ensure that you restart Visual Studio.
How to Download C# 9.0 Preview , Install and Try ?
  • Once you have .NET 5 Preview SDK installed , create a empty console application (.NET Framework) and add any of the C# 9.0 features to your code : FOr example , lets add the init properties features of C# 9.0 in your newly created project.

Visual Studio Intellisense is smart enough to inform you that you are using C# 9 language feature and will allow to add the necessary configurations to use C# 9.0 automatically.

Error CS8652 The feature ‘init-only setters’ is currently in Preview and unsupported. To use Preview features, use the ‘preview’ language version

How to Download C# 9.0 Preview , Install and Try ?

Just click on the Upgrade the project to C# language version preview to use C# 9.

How to Download C# 9.0 Preview , Install and Try ?

If you are using Visual Studio 2019 Preview 16.8 , you will notice additional error in your .NET standard application.

“Predefined type ‘System.Runtime.CompilerServices.IsExternalInit’ is not defined or imported”.

To fix , this error , simply add the missing type somewhere in your project so that the error is suppressed. This seems to be a known bug in the Preview version.

namespace System.Runtime.CompilerServices
 	public class IsExternalInit{}

Incase you are using .NET Core Console application targetting .NET 5 , you will not have the above error.

Note : Do not install and try the preview versions on your primary workstation. Try them on a secondary many that you don’t use it for day to day work. I usually have a VM on Azure which I use it for installing the preview versions for demo purposes.