AQA Computer Science A Level

Hello World
By Admin - April 15, 2020, 11:01 a.m.
Last Edit - Oct. 6, 2020, 8:56 a.m.

In Visual Studio, when you create a C# Console Application the basic structure of a C# program is also created. The key part of this is the static void main().

This is the section of your program which will automatically run when you run your program. Anything outside of this will only be run if something inside the static void main() calls the code.

So inside the { } of the static void main() add the following line:

Console.WriteLine("Hello World");

Some key things to take from this simple line:

When you run this, your computer can execute so many instructions per second that you will see a window flash up. This will be too quick to read. So after the Console.WriteLine(); add:

Console.ReadLine();

This is line will make your program wait unitl the enter key is pressed.