A string is a series of characters. Think of it as a sentence or a word.
For this example I used the classic two words “Hello World”
Now the simplest way to do this is by printing the string directly to the console so the users can see it.
To do this you need the following code:
Console.WriteLine("Hello World");
This is telling the computer here is exactly what I want you to print onto the screen inside the brackets.
For a deeper explanation see This Post.
Another way of doing it is by using the code below:
string game;
game = "Hello World";
A string tells the computer I am going to write a string of letters. For example H then E then L then L then O and so on.
That string is then assigned to a variable called ‘game’ as you can see in the top line of code (obviously, you can choose your own name).
On the next line, I use the ‘=’ to tell the computer what string of letters we want to give to ‘game’ to assign it a variable.
After the = you want “” . Anything typed within the “” will shown on the console when we display ‘game’. Note that the “” will not appear. Finally don’t forget the semi colon to finish the line.
To place this onto the console, we use the following piece of code:
Console.WriteLine(game);
Console.WriteLine() tells the computer I want to put the variable inside of the brackets onto the screen. So when you specified ‘game’ as the variable it knows to display the string defined as ‘game’ as we get this…
Hello World
For more clarification on the Console.WriteLine() command see this post.
Comment any questions below!
Other helpful links



Leave a comment