×

c# · level 1 · unit 2 · lesson 2

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

Put something new in a box and the old thing is gone.

A box holds one value at a time. Put a new value in and the old one is thrown away. We say you it. Write the type only once, when you first make the box.

You can copy one box into another, like string order = drink;. You can also strings with +, which sticks them end to end, so mind the spaces.

A box can even use its own value. score = score + 1; takes what is in score, adds one and puts the answer back in.

using System;

string drink = "tea";
drink = "coffee";
Console.WriteLine("I would like " + drink);
int score = 5;
score = score + 1;
Console.WriteLine(score);

Write the type again, like int score twice, and C# stops with CS0128, because that name is taken.