Hello World

View saved

Scaffold a project

Use the console template for a minimal app.

dotnet new console -n HelloWorld -o HelloWorld
cd HelloWorld

Print a message

Top-level statements let you write code without wrapping it in a Main method.

Console.WriteLine("Hello, World!");

Run the app

Restore, build, and run with one command.

dotnet run

Classic Main form

Older tutorials show an explicit Program class. Both styles are valid.

namespace HelloWorld;

class Program
{
    static void Main()
    {
        Console.WriteLine("Hello, World!");
    }
}

Comments

One comment per signed-in account. Comments are saved with this page’s URL.