c# · level 1 · unit 2 · lesson 3
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
Give every box a name that tells you what is inside.
Names can use letters, digits and _. They cannot have spaces and cannot start with a digit. Capitals matter, so score and Score are two different boxes.
Some words are taken. A such as int, string or using already means something to C#, so it cannot be a name.
For names made of several words, C# coders use : squash the words together and give each new word a capital, like favouriteFood. Pick names that say what is inside.
using System;
string favouriteFood = "pizza";
int bestScore = 120;
Console.WriteLine(favouriteFood);
Console.WriteLine(bestScore); A box called x works, but bestScore tells you what it holds.
guess first
One capital letter. What happens?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
using System;
int score = 10;
Console.WriteLine(Score);
your turn
Your turn. Name a box for your pet.
Make up a camelCase name, like petName, and type it in the first and last blanks. Put a pet's name between the quotes, then run it.
output
press run to see what happens
fix it
This name has a space in it. Can you fix it?
output
press run to see what happens
- C# says it expected a comma on line 3. It thinks the name stopped at the space.
- Names cannot have spaces. Squash the two words together into one name.
- Write
favouriteColour, with a capital C, on lines 3 and 4, then press run.
nailed it
your boxes have good names now. :D
- Names use letters, digits and
_, with no spaces. - Keywords like
intare taken, and capitals matter. - Use camelCase names that say what is inside.
new words in your collection
- keyword
- camelCase
This lesson isn’t saved. A free account remembers every lesson you finish.