c# · level 1 · unit 1 · lesson 3
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
Lines run in order, one after another.
A program can have lots of lines. C# runs them in order, top to bottom, like ticking off a shopping list. Everything your program shows on the screen is called its .
An empty Console.WriteLine() has nothing to show, so you get a blank line. It is handy for spacing things out.
WriteLine moves to a new line after showing its text. Its cousin , with no Line, stays on the same line, so the next text carries straight on.
using System;
Console.WriteLine("Ready");
Console.WriteLine("Steady");
Console.WriteLine();
Console.Write("Go, ");
Console.WriteLine("go, go!"); Write and WriteLine both show text, but only WriteLine moves down afterwards.
guess first
How will this look on the screen?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
using System;
Console.Write("Fish ");
Console.Write("and ");
Console.WriteLine("chips");
your turn
Your turn. Write a knock knock joke.
Type who is at the door on lines 5 and 6, the same both times. Put your punchline on line 8, then press run and enjoy your output.
output
press run to see what happens
fix it
The shopping list is all squashed up. Can you fix it?
output
press run to see what happens
- Run it and look at the output. The three items land on one line as MilkBreadJam.
Writestays on the line. Which command moves to a new line afterwards?- Change
WritetoWriteLineon lines 4, 5 and 6, then press run.
nailed it
you made the computer tell a joke. :D
- Lines run in order, from top to bottom.
- An empty
Console.WriteLine()makes a blank line. Writestays on the line.WriteLinemoves to a new one.
new words in your collection
- output
- Console.Write
This lesson isn’t saved. A free account remembers every lesson you finish.