Numeric Types
int, double, decimal and more.
Why Numeric Types Matter
C# offers several numeric types, each storing a different range of values and using a different amount of memory.
Choosing the right one keeps your programs correct and efficient. A whole number like the count of users fits an int; a price needs decimals.
In this lesson you'll meet integers, floating-point, and decimal types.
Integer Types
Integers store whole numbers with no fractional part.
int— 32-bit, the everyday defaultlong— 64-bit, for very large countsshortandbyte— smaller ranges
Use int unless a value can exceed about two billion.
int age = 30;
long population = 8000000000;
Console.WriteLine(age);
Console.WriteLine(population);