1. What is this?
A variable is a named slot. A type fixes what fits: int (whole numbers), double (decimals), string (text), bool (true/false). string name = "Ava" means 'slot name holds text, starting at Ava'. var lets the compiler infer the type, but explicit types teach you more at first.
2. Why do we use it?
Types document intent and catch mistakes before users see them.
3. Syntax breakdown
string name = "Ava";
Text variable. string is lowercase in C#.
int age = 28;
Integer variable.
System.Console.WriteLine($"{name} is {age}");$ enables { } substitution (interpolation).
5. Common mistakes
- Forgetting $ before an interpolated string, so {name} prints literally.
- Assigning "28" to an int.
- Comparing with = instead of ==.
Practice task
Add string city = "Berlin"; and print "I live in Berlin." with interpolation.
Hint
WriteLine($"I live in {city}.");
Try it below — tests run automatically when you press Run.
Output
Press Run to see output.
Mini quiz
3 questions. Answer, then check.
1. Which type holds text in C#?
2. What does $"...{x}..." do?
3. Which holds whole numbers?