Search code examples
c#dotnet-cli.net-7.0

How can I disable Top-level statements when using `dotnet new console`?


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.