Below are step by step instructions for creating your first program using Microsoft Visual Studio. By the end of this tutorial, you will have a console program that will display the message "Hello World" when run.
The C# programming language runs on what are called "classes" and "methods." When you just copied that code into your program, you unknowingly were using these components with each line written. But exactly what did these couple of lines of code mean, you may wonder? Here is a brief explanation.
Console.WriteLine: In this line of code, you are telling the computer that you are using the "Console" class to perform the method "Writeline". This means you are telling it to use its console (the black screen that came up when you hit start) to literally write a line of text.
("Hello World"); This line of code is telling the computer what it should output when it performs the Console.WriteLine task. This line is what tells it to say Hello World. Important to notice is the semicolon (;) put at the end of the line. In a C# program, every line of code ends with a semicolon - that's what tells the computer that the line just ended.
Console.ReadLine(); This is another essential line of code. This code tells the program to wait for you to hit a key before continuing - which is very important because after this line all the program has left to do is end. In order to understand how important this is, just try deleting this line of code, then run the program again. Most likely, your program would just flash open and then close again instantly.