Don’t need Program class and Main method for simple apps. Write code directly.
Old Way:
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");
}
}
}
New Way (.NET 6+):
Console.WriteLine("Hello World");
That’s your entire Program.cs file! Compiler generates the boilerplate.
Can Still Use Services:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", () => "Hello");
app.Run();
