0
0
C Sharp (C#)programming~5 mins

Console.WriteLine and Write methods in C Sharp (C#) - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does Console.WriteLine do in C#?

Console.WriteLine prints text or values to the console and then moves the cursor to the next line.

Click to reveal answer
beginner
How is Console.Write different from Console.WriteLine?

Console.Write prints text or values to the console but does NOT move to the next line, so the next output continues on the same line.

Click to reveal answer
beginner
What will this code print?<br>
Console.Write("Hello");
Console.WriteLine("World");

This will print HelloWorld on one line, then move to the next line after printing "World".

Click to reveal answer
beginner
Can Console.WriteLine print variables? How?

Yes, you can print variables by passing them inside Console.WriteLine. For example: Console.WriteLine(myVariable); prints the value of myVariable.

Click to reveal answer
beginner
What happens if you use Console.WriteLine() with no arguments?

It prints an empty line and moves the cursor to the next line, creating a blank line in the console output.

Click to reveal answer
Which method moves the cursor to the next line after printing?
AConsole.Clear
BConsole.Write
CConsole.ReadLine
DConsole.WriteLine
What will this code output?<br>
Console.Write("Hi");
Console.Write(" there");
AHi there (on one line)
BHi (newline) there
CHi\n there
DError
How do you print a blank line in the console?
AConsole.Clear()
BConsole.WriteLine()
CConsole.ReadLine()
DConsole.Write()
Which method would you use to print a variable's value followed by a new line?
AConsole.ReadLine(variable)
BConsole.Write(variable)
CConsole.WriteLine(variable)
DConsole.Clear(variable)
What is the output of:<br>
Console.WriteLine("A");
Console.Write("B");
Console.WriteLine("C");
AA (newline) BC (newline)
BABC (newline)
CA B C (all on one line)
DError
Explain the difference between Console.Write and Console.WriteLine.
Think about what happens to the cursor after printing.
You got /3 concepts.
    How can you print multiple pieces of text on the same line using Console methods?
    Consider how the cursor moves after each print.
    You got /3 concepts.