I've inherited a C# (.NET 7.0) project that includes program files written in the newer "top-level statement" style. I need to change these to the classic C# program file style. Is there a quick and easy way to do this?
The research I've done suggests that I can use ReSharper to do this. But our company does not have a ReSharper license. Thus, I need a way to accomplish this using only the built-in Visual Studio tools or by manually editing the project file.
Is there a quick and easy way to do this?
Using the Visual Studio code fix, put the cursor in a line of code and pick "To explicit Program class":
Otherwise:
Program.cs
file in VS.public static class Program{ public static async Task Main() {
} }
..csproj
file should be necessary.using
statements to the top of the file.