Variables & Data Types

Variables = Labeled Boxes

A variable stores data. You must tell C# what type of data it holds.

int age = 21;              // Whole numbers
string name = "Kunal";     // Text
double price = 99.99;      // Decimals
bool isPaid = true;        // True or false

The Big 4 Types

TypeExampleReal use
int21Age, quantity, ID
double99.99Price, weight, rating
string"Kunal"Name, email, address
booltrueIs logged in? Is admin?

Shortcut: var

var city = "Mumbai"; // C# knows this is string

Quick Check ๐Ÿง 

Q: You need to store the price of a product โ‚น1,999.99. Which is best?

Comments on Variables & Data Types (0)

No comments yet. Be the first to share your thoughts!