Chapter 2: Living with Variability — Declaring Value-Type Variables
In This Chapter
Visiting the train station — the C# variable as storage locker
Using integers — you can count on it
Handling fractional values — what’s half a duck?
Declaring other types of variables — dates, characters, strings
Handling numeric constants — Π in the sky
Changing types — cast doesn’t mean toss
Letting the compiler figure out the type — var magic
The most fundamental of all concepts in programming is that of the variable. A C# variable is like a small box in which you can store things, particularly numbers, for later use. (The term variable is borrowed from the world of mathematics.)
Unfortunately for programmers, C# places several limitations on variables — limitations that mathematicians don’t have ...