This is a quick tutorial on how to display content to the screen.
To do this you are going to use Console.WriteLine() function as follows: –
Console.WriteLine();
This is a very simple piece of code.
Essentially you are telling the computer to write something so that the user can see it on the console. Whatever is inside the brackets after this command is what is going to appear on the console.
For example if we wanted to print a string it would look something like this:
Console.WriteLine("Hello World");
Whatever is within the brackets will be shown to the console but the “” that hold the string will not be shown.
Here is another example
string game = "Hello World";
Console.WriteLine(game);
This will achieve the same console output as the example above except you have previously defined the variable and clarified it as a string.
By telling the console to print a variable, it will go and retrieve this variable and then print it on the console. This can be referred to as “getting the variable”.
This same concept applies to printing any other variable. If you define the type and then give it a name and ask the computer to print that using the Console.WriteLine(); command, it will do so.
For another example on how to do this on something other than a string see This Post
Comment any questions below!



Leave a comment