I created a C# project with the below command in VSCode and enabled Top-level statements automatically for this project.
How can I disable Top-level statements in Visual Studio Code for a C# project?
dotnet new console –framework net7.0
>Solution :
Add --use-program-main. See the documentation for details.