Follow us

.Net 5.0 or C# 9.0 - Preview

 

For installation 5.0 Preview,

  • First you can check your installer if it have the preview version available for install and then install it and then in next step, do option allow to use preview option. As next you may need to install the SDK of .net 5 as well for core. So look at below all 3 screenshots. Or
  • If no preview version is available with visual studio installer then download the visual studio respective preview version and install it including .net 5 sdk.

 

             

 

                 https://dotnet.microsoft.com/download/visual-studio-sdks

          

 

                   Or download the visual studio respective preview version and install and you may need to install the above .net 5 sdk as well.

 

              

 

In my case : I have I have done the installation of Visual Studio Preview version and then created .net core console application to test some below codes of new features.

 

Features

1. Top Level Program

With this feature actually it remove the "Main" function to have mandatory option, so now without main function you can run your C# program. So it quite similar to JavaScript code you write, here just your write your method, class everything just after declaring using statement and it will work.

Few things/concepts to remember-

  • Within your one application/project you can have only one file which you can have top level program i.e. without main.
  • If you class file have both the "top level program" and "main function" then it will ignore the main.
  • You can write "top level program" with any of the file and that file will become your entry point for the project.

 

Example 1 : Here just I have "top level program" and also "main method", so it is ignoring main and only "top level code" will run.

 

Example 2 : Here just I have "top level program" with other file and that will become the entry point and will ignore the "program/main" and also here I am even calling the other class method as well.

 

 2. Pattern Matching

With this again we have new way of wring conditions, so if you see I have normal approval and the new pattern matching approach to make and condition for one of the class object two variables.

Categories/Tags: .Net 5.0~C# 9.0

Recent Articles

1

AWS Saving Plan - Cost optimization tips

2
3

AWS RDS Key Concepts & Why you should use it?

4
5

Open-Search/Kibana - Multi Tenancy Setup

See All Articles