×

c# · level 1 · unit 3 · lesson 1

  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

Quotes turn a number into text.

5 is a number. "5" in quotes is a string that looks like one, and C# treats them very differently. 5 + 3 adds up to 8, but "5" + "3" joins into 53.

Whole numbers go in int boxes. Numbers with a decimal point, like 0.75, go in boxes. Each box only takes its own type, so text in an int box gives error CS0029.

Console.ReadLine() always gives back text. To do maths with it, it first. turns the text "12" into the number 12.

using System;

int apples = 5;
double price = 0.75;
Console.WriteLine(5 + 3);
Console.WriteLine("5" + "3");
Console.WriteLine("Apples: " + apples);
Console.WriteLine(price);
int candles = int.Parse("9");
Console.WriteLine(candles + 1);

int.Parse only works on text that looks like a whole number, so int.Parse("cake") gives an error.