×

c# · level 1 · unit 3 · lesson 4

  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 $ before the quotes to fill gaps in your text.

Joining with + gets messy. Put $ before the opening quote instead, and anything inside {} is swapped for its value. This is string , like filling in the gaps on a birthday card.

A gap can hold a box name, like {name}, or a sum, like {age + 1}. C# works out the value and drops it into the text.

Forget the $ and C# leaves the curly brackets alone. It prints them exactly as you typed them.

using System;

string name = "Sam";
int age = 9;
Console.WriteLine($"Happy birthday, {name}! You are {age}.");
Console.WriteLine($"Next year you will be {age + 1}.");

The $ goes right before the opening quote, with no space between them.