Write it
Open a terminal and type dotnet new console -o Hello. It makes a folder called Hello with two files: Hello.csproj, the project file with its settings, and Program.cs, where your code goes. Then cd Hello moves into that folder.
A statement is one instruction, ending with a semicolon (;). The template Program.cs holds just one, which prints Hello, World!. We add three more and a comment. These top-level statements run in order, from top to bottom.
Line 1 starts with //, so it is a comment: a note for people who read the code. The compiler skips everything from // to the end of the line. A comment never changes what the program does.
Console is a class from .NET that talks to the terminal. The dot reaches inside it for WriteLine, a method: a named action. The brackets pass it a string literal, text in double quotes. The semicolon ends the statement.
Build and run
Type dotnet run. First it builds: the C# compiler checks every line. A typo, such as a missing semicolon, stops the build with error CS1002 and nothing runs. With no errors, it writes Hello.dll.
Then dotnet run starts the .NET runtime, which loads Hello.dll and runs your statements one at a time, top to bottom. The blinking cursor shows where the next text will appear in the terminal.
Line by line
Line 2 runs. Console.WriteLine sends Hello, World! to the terminal and then a line break. So the cursor jumps down to the start of the next line.
Line 3 uses Console.Write, without Line. It prints Your name? and no line break, so the cursor waits right after the question mark and the space. That break is the only difference between Write and WriteLine.
Line 4 calls Console.ReadLine. The program stops and waits. You type Ada and press Enter. ReadLine returns the text Ada, and var name = keeps it in a variable: a named box in memory called name.
Line 5 starts its string with $, which makes it an interpolated string: {name} is replaced by the value of name. So WriteLine prints Hi, Ada! and a line break.
After the last statement there is nothing left to run, so the program ends with exit code 0, which means success. Its memory, name included, is given back. The terminal shows its prompt again.
What happens
// step 1/11 · new-project
$ dotnet new console -o Hello
Hello/
Hello.csproj the project file: settings, target framework
Program.cs your code
$ cd Hello go into the folder
The letters you type are shown by the terminal, not by the program (the terminal echoes them). If the input came from a file instead, the program's own output would be Hello, World!, then Your name? Hi, Ada! on one line. WriteLine ends the line with Environment.NewLine: a line feed (\n) on macOS and Linux, a carriage return and line feed (\r\n) on Windows.