Writing to Console
Writing to Console
Console.WriteLine
means to tell the computer to print the sentence enclosed within the parentheses ()
out onto the console.
Working Together
- In the Fiddle program below, press run. You see that
Hello World
is printed out to the screen on the right. - Without removing the quotation marks, try changing
"Hello World"
to another sentence. Press run to see if anything changes. - Add another
Console.WriteLine
below the current line to print a second sentence below the first sentence. - Press run to see if two sentences are printed out. If you see any red text, please ask for help.
We will use printing heavily in the later lessons, so make sure you understand this before continuing!
HELP! I got a lot of red text!
If you see any red text, you have encountered some errors! Please ask for help or check the debugging page at the end of this tutorial. Beware of the following when coding in C#:
- The
c
inConsole
, and thew
andl
inWriteLine
are capitalized. - There is a semicolon
;
at the end of the line. - Make sure the sentence you wish to print is surrounded in quotation marks, and that the sentence is between the parentheses.
- Do not delete any curly braces
{
or}
.