Monday, November 28, 2022
HomeC#The right way to get again the previous Console Venture in .NET...

The right way to get again the previous Console Venture in .NET 6


Since .NET 6, Microsoft has modified the template for the console venture.

Any further, the console template will use top-level statements. Utilizing new options like world usings and file-scoped namespaces, .NET means that you can write the code statements instantly with out boilerplate code.

Most programmers hate this new venture fashion that removes the Most important methodology and the default utilizing statements. I embody myself on this class, and I would like my previous template again, so I’ve looked for choices.

Goal .NET 5 framework as a substitute of .NET 6

The simplest choice is to decide on .NET 5 goal framework once you create a brand new venture. Then you definately edit the venture file and swap again to .NET 6.

Console Project - choosing the target framework

After you create the venture, you may edit your csproj file and swap again to .NET 6:

<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>allow</ImplicitUsings>
<Nullable>allow</Nullable>

Copy the previous template from the documentation

Another choice is to only copy the previous template from the documentation:

utilizing System;

namespace Utility
{
    class Program
    {
        static void Most important(string[] args)
        {
            Console.WriteLine("Hey World!");
        }
    }
}

Set up Basic Console Template

Visible Studio means that you can create and set up templates.

There’s a template referred to as Basic Console Template that means that you can create an previous console venture that targets .NET 6. That is by far the cleanest choice.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments