How to use the old console app structure in .NET 6.0 console app?

john zyd 421 Reputation points

As I begin to use Visual Studio 2022, I want to port some old code from .NET 5.0 to .NET 6.0 on Windows 10.
However, I found in the new IDE, the old console app structure is gone.
For example, the old console app is something like this:

using System;
namespace ConsoleAppDemo
class ConsoleAppDemo
public static void Main(string[] args)
Console.WriteLine("Hello World!");

But in .NET 6.0, when I created a new Console App project, I see there is only one statement, the others are gone.
Since in my old code (.NET 5.0), I have many methods to call, and many properties to access.
With the old console app structure, it is easy to know where those methods/properties are located, but the new structure, which contains only one statement. Then how I can know where to call/access the methods and/or properties?
Please advise, how I can change the IDE, so I can get the old console app structure back.

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,218 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jaliya Udagedara 2,731 Reputation points MVP

    If you want to Use the old program style,

    • Create a new project dotnet new console --framework net5.0
      • Open the project file in a text editor and change <TargetFramework>net5.0</TargetFramework> to <TargetFramework>net6.0</TargetFramework>

    More Information:

    If you prefer to use Visual Studio, Create a new Console Application.

    Choose Target Framework as .NET 5:

    And then if you want to use all the nice C# 10 and .NET 6 features, update the csproj file as above.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Karen Payne MVP 35,031 Reputation points

    Download the following .zip file (basic console app, .NET Core 5, C#9)!AtGAgKKpqdWjkgHTf5WflrRfIZKY?e=S3bWLq

    Copy it to

    C:\Users\TODO\Documents\Visual Studio 2019\Templates\ProjectTemplates

    Open Visual Studio, create a new project, search for Console

    See it, select it


  2. Bruce ( 55,196 Reputation points

    You can declare a static main, it’s optional. Generally there is little code in the program.cs file, just the startup logic.

    You can add static methods and classes to program.cs, they just go after the startup code.

    0 comments No comments