Click here to Skip to main content
15,392,078 members
Articles / Programming Languages / C#
Posted 22 May 2022

Tagged as


9 bookmarked

Why We Need to Move from .NET 5.0 to .NET 6.0

Rate me:
Please Sign up or sign in to vote.
3.62/5 (8 votes)
22 May 2022CPOL5 min read
Why should we move our existing projects from .NET 5.0 to .NET 6.0
In this article, we will see why we need to move our existing projects from .NET 5.0 to .NET 6.0. We will also see why we need to start with .NET 6.0 instead of .NET 5.0 for all our new projects.


In March 2022, Microsoft announced that as of 10th May, 2022, Microsoft will stop all the support which also includes security support and technical support. Check this article for more details from the official Microsoft announcement.

Microsoft also stated in the above blog that the existing users can still run the .NET 5.0 for their current project, but at the same time if the users need any security support or technical support, then it's not possible after May 10th, 2022.

Do We Need to Move or Start With .NET 6.0?

Yes, we need to migrate from .NET 5.0 to .NET 6.0.

The main reason why I recommend this is because more than technical support, Microsoft is also stopping the security support of .NET 5.0. Security support is more important than technical support as in future, if we find any vulnerability in .NET 5.0, then Microsoft cannot provide support on any security issues. Considering the security and technical support, it is good and advisable to migrate our current project from .NET 5.0 projects to .NET 6.0 and create all our future projects in .NET 6.0.

In this article, we will be seeing in detail how to get started with .NET 6.0 by installing Visual Studio 2022.

If you would like to learn about migrating your existing project from .NET 5.0 to .NET 6.0, then go through these links:



  • Visual Studio 2022

Visual Studio 2022

If you have not yet installed Visual Studio 2022, then you can download the Visual Studio 2022 from this link and install it on your computer.

Download and install Visual Studio 2022.

Image 1

Note: The Community version is free for all and you can download the community version if you don’t have the Installation Key. If you have the Installation key or have the MSDN subscription, then you can download the Professional or Enterprise version.

As a Microsoft MVP, I have the MSDN subscription and I have installed the Professional version.

Image 2

Getting Started with .NET 6.0

.NET 6.0 has more advantages than working with the .NET 5.0. As .NET 6.0 has more improvement on the performance which also includes one major advantage as it has the intelligent code editing and also it is called as the fastest full stack web framework. The .NET 6.0 also provides better performance in the File Stream.

We will see a demo on creating console application in .NET 6.0 and also, we will see what advantage the Console application has in .NET 6.0 with example of intelligent code editing.

Using the Code

Create .NET 6.0 Console Application

After installing all the prerequisites listed above and clicking Start >> Programs >> Visual Studio 2022 >> Visual Studio 2022 on your desktop, click New >> Project.

Image 3

Click on Console App and click Next.

Image 4

Enter your project name and click Next.

Image 5

Now we can see as the Framework is .NET 6.0 (Long term support). Click on the Create button to create our first .NET 6.0 Console application.

Image 6

When we create the new console application, we can see very simple code in our program.cs file.

Image 7

.NET 5.0 and Previous Versions of .NET

In .NET 5.0 and previous version for any console application, we can see the main method, class, namespace and the using header files. Without any of the below code, the program cannot be executed.

Image 8

.NET 6.0 Console Application

We can see that as there is no main method, class and using headers in the program.cs file, don’t panic, yes, now in .NET 6.0, codes are made simpler and the intelligent code supports seem to be more advanced and now it’s easier and reduce the time on working our codes and projects.

Top-Level Statements

This is called as the Top-Level statements as the main method is not needed from C#9. The main aim of the Top-Level statement is to reduce the code and improve the performance. The main method and the class will be created by the compiler as we do not need to write separate code for it.

After the Top-Level statements were introduced from C# 9.0, now it seems more easy for programming and easy to learn C#. Yes, now it seems like Small Basic programming and makes it easier for programmers to getting started and working on codes.

Image 9

When we run the program or press the F5 button from the application, we can see as the .NET 6.0 can run without any errors even if the main method is missing.

Image 10

.NET 6.0 Intelligent Code Editing

In the same application, I will add the code to get the name and display the name in command prompt.

For this, I have declared the string as myname and using the Console.ReadLine() method, the input from the user and display the results.

You can see as when I enter the Console and press the Tab, the code is automatically generated and also the intelligent code has automatically added the string as myname to be displayed.

This reduces the coders' workload 😊, also happy to work with Intelligent Code editing as it's also fun to work with the codes.

Image 11

When we run the program and enter the name in command prompt and press Enter, we can see the result as below:

Image 12

Working with Simple Methods in .NET 6.0

Here, we will see two ways of creating the functions in .NET 6.0 as in the first method for all the single like statements, it's more easy to follow the method format with the => codes and for all the multiple statements, we can use the {} brackets as we do earlier.

// See for more information
Console.WriteLine("Hello, World!");
Console.Write("Enter Your Name My Friend");
String myname=Console.ReadLine(); 
void displaymyname() => Console.WriteLine("Welcome " + myname + " to .NET 6 World");
void mynamesdisplay()
    Console.WriteLine("Welcome " + myname + " to .NET 6 World");

When we run the application and enter the name, we can see as both the methods are called and displayed the results.

Image 13

Points of Interest

Hope this article help you to understand why we need to migrate or started working with .NET 6.0. I have also explained the basic importance and few advantages of .NET 6.0. As I mentioned in this article mainly for security updates and concerns, we need to move from .NET 5.0 to .NET 6.0.


  • 23rd May, 2022: Version 1.0


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

syed shanu
Team Leader
India India
Microsoft MVP | Code Project MVP | CSharp Corner MVP | Author | Blogger and always happy to Share what he knows to others. MyBlog

My Interview on Microsoft TechNet Wiki Ninja Link

Comments and Discussions

GeneralWhy care about "security support"? Pin
Andreas Saurwein31-May-22 7:07
MemberAndreas Saurwein31-May-22 7:07 
GeneralMy vote of 5 Pin
Ștefan-Mihai MOGA22-May-22 23:33
professionalȘtefan-Mihai MOGA22-May-22 23:33 
This is a great inspiring article. I am pretty much pleased with your good work. You put really very helpful information. Keep it up once again.
GeneralRe: My vote of 5 Pin
syed shanu23-May-22 13:00
professionalsyed shanu23-May-22 13:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.