c# · level 1 · unit 1 · lesson 2
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
shows a message on the screen.
Console.WriteLine is a command that shows something on the screen. Read it as: console, write a line. The console is the window where your program talks. Whatever you put inside the brackets is what appears.
Words go inside double quote marks, like "Hello, world!". A piece of text in quotes is called a . Picture the letters threaded on a string, like beads. The quotes are not shown.
Every instruction ends with a , ;. It works like the full stop at the end of a sentence, telling C# that this instruction is finished.
using System;
Console.WriteLine("Hello, world!"); Use a capital C in Console, a capital W and L in WriteLine, and double quotes at both ends.
guess first
What will appear on the screen?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
using System;
Console.WriteLine("My cat is called Pickles");
your turn
Your turn. Tell the computer what you love to eat.
Type your favourite food in place of the blank, keeping it inside the quotes. Then press run.
output
press run to see what happens
fix it
This line will not run. Can you fix it?
output
press run to see what happens
- C# stopped before showing anything. Look at the very end of line 3.
- Every instruction needs a mark at the end, like the full stop at the end of a sentence.
- Add a semicolon,
;, after the last bracket on line 3, then press run.
nailed it
you made the computer talk. :D
Console.WriteLineshows whatever is inside its brackets.- Text inside double quote marks is called a string.
- Every instruction ends with a semicolon.
new words in your collection
- Console.WriteLine
- string
- semicolon
This lesson isn’t saved. A free account remembers every lesson you finish.