Thuta Learning
BasicProgrammingbeginner

Variables

Relax. We'll talk through this in plain words — no textbook voice.

A variable is basically a little box that holds data. In C#, you have to specify the data type before declaring a variable. That way, the compiler can catch data type mistakes while you're still writing the code.

csharp
string name = "Aung";
int age = 30;
double height = 5.8;
bool isStudent = false;

Console.WriteLine("Name: " + name);
Console.WriteLine($"Age: {age}");
Console.WriteLine($"Height: {height}");
Console.WriteLine($"Student: {isStudent}");

What this code does

  • string holds text.
  • int holds whole numbers.
  • double holds decimal numbers.
  • bool holds true or false.
  • $"Age: {age}" is string interpolation — a cleaner way to drop a variable's value into a string.
You should see
Name: Aung Age: 30 Height: 5.8 Student: False

Info

⚠️ Common mistake

int age = "30"; will throw an error. "30" is text, while 30 is a number. Whether or not you add quotes changes the data type entirely.

Variables | Thuta Learning