Microsoft recently released .NET Core 3 Preview 2 and includes more features for both .Net Core 3.0 and C# 8. .NET Core 3 will be supported in Visual Studio 2019, Visual Studio for Mac and Visual Studio Code. Visual Studio 2019 Preview 2 was released last week and has support for C# 8.
Now lets see some of the latest feature in C# 8.0:
With latest C# 8.0, you can now attache the using declaration to the scope of the current block of code and later you can dispose the object at the end. Below is the example.
One of the features which I really liked in C# 8 is the Switch Expression. Let's take the example and you will be able to understand properly.
In the above example you can see that first you don't need to declare the variable or explicit type each of the cases. Switch expressions enables terser syntax, returns a value since it is an expression, and fully integrated with pattern matching.
Code Source: Microsoft
Microsoft recently released .Net Core 3 and it has really couple of important updates. Windows Forms/WPF development on top of .NET Core, and C# 8. So in the below post I will help you to setup .Net Core 3 and C# 8.
Installing .Net Core is simple and straight forward, just browse to its download page and install SDK. Once installation is successful, open command prompt and run “dotnet –info” and you should get the below output.
The first version of Visual Studio to support .NET Core 3.0 is Visual Studio 2019 Preview 1, so you need to install Visual Studio 2019 to use .Net Core 3 and you can download it from here.
To enable C# 8.0 on a project, open the .csproj file in notepad and add the below code: