Python Variables & The C# Type System
C# is a strongly typed language where every variable has a defined type. C# offers rich primitives for numbers (int, double, decimal), text (char, string), boolean logic (bool), and smart type inference using the var keyword.
"Variables are like labeled storage containers. You have a rigid steel box for whole bricks (int), a glass beaker for liquids with decimals (double), a cash register drawer for financial currency (decimal), and an envelope for letters (string)."
Deep Dive: How It Works
int: 32-bit whole integer (e.g. 42, -500).
double: 64-bit floating-point number (e.g. 3.14159). Fast, great for graphics and scientific math.
decimal: 128-bit ultra-precise decimal (e.g. 19.99m). Mandatory for financial and currency calculations to prevent floating-point rounding errors! (Requires "m" suffix).
bool: true or false.
char: Single Unicode character in single quotes (e.g. 'A', '#').
string: Sequence of characters in double quotes (e.g. "ZenCompiler").
var: Implicit typing—the compiler infers the exact type automatically from the assigned value (e.g. var speed = 100; becomes an int).
Syntax Blueprint
int score = 95; double speed = 88.5; decimal price = 14.99m; bool isReady = true; string name = "Neo"; var count = 10; // Inferred as int
Explicit typing (<type> <name> = <val>;) or implicit typing with var.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Forgetting the 'm' suffix on decimal: decimal price = 9.99;Why it happens: C# defaults decimal numbers to double without a suffix.
How to fix: Always write decimal price = 9.99m;.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Declare player variables
Declare string playerName = "Valkyrie";
Declare int health = 100;
Print "Player Valkyrie has 100 HP" by concatenating these variables.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.