C# FOUNDATIONSChapter 1 · C# Foundations
Variables and types
C# is statically typed, so every variable has a type. Use int for whole numbers, string for text in double quotes, and bool for true or false. The keyword var lets the compiler infer the type for you.
Worked example
int stars = 100; string sky = "neon"; bool isClear = true; var mood = "dreamy"; Console.WriteLine(stars); Console.WriteLine(sky);
How it reads
- int stars = 100; declares a whole-number variable named stars
- string sky = "neon"; holds text, always in double quotes
- var mood lets the compiler infer the type from the value

Cloud tip: In C#, double quotes make a string and single quotes make a single char. They are not interchangeable.


