Primitive Data Types
A free lesson from Swipe Coding · C#, level 2 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
Every variable in C# needs a type, and the built-in primitive types are the most basic kinds of data a variable can hold. Primitives store a simple value directly, which makes them fast and memory-efficient — unlike the string type you will meet soon, which is a reference type.
int quantity = 10; double price = 4.99; bool inStock = true; char grade = 'A';
int stores whole numbers (no decimal point) and is the default choice for counting things. double stores decimal numbers and is the default choice for anything with a fractional part, like prices or measurements. bool can only ever be true or false, which makes it perfect for yes/no conditions — note that C# spells it bool, not boolean. char stores exactly one character, written in single quotes like 'A' — never double quotes, which are reserved for strings.
To store a single character like 'A', you use the ____ type.
C# also has smaller and larger whole-number types for when int isn't the right fit: byte and short save memory for tiny numbers, while long is used for whole numbers bigger than int can hold — you mark a long literal with an L at the end. For money and other values needing exact decimal precision, C# offers decimal, marked with an m suffix; it is more precise than double but slightly slower to calculate with.
long population = 8_000_000_000L; byte smallNumber = 120; decimal price = 19.99m;
Fields that belong to a class automatically get a default value if you don't initialize them — 0 for numeric types, false for bool, and a null character for char. Local variables declared inside a method, however, do not get a default value: the compiler forces you to assign one before you can use the variable, which helps catch bugs early.
A local variable declared inside a method automatically gets a default value, like 0, if you never initialize it.
Which primitive type would you use to store whether a light switch is on or off?
Variables & Primitive Types
10 questions · pass with 60% — just like in the app.
What must every variable in C# have?
In C#, variable names are case-sensitive, so score and Score are different variables.
C#'s naming convention for local variables is ____, e.g. totalScore.
Which statement correctly declares and initializes an int variable named age?
You can declare a variable without giving it a value right away, as long as you assign one before using it.
The ____ type stores whole numbers and is the most common choice for counting things.
Which type would you use to store a value like 4.99?
A local variable inside a method automatically receives a default value if you don't initialize it.
A long literal in C# must end with the letter ____.
What happens when you reassign a variable that already holds a value?
Keep your streak going in Swipe Coding
Swipe through every level of C# on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.
Get the Swipe apps →