1. Variables (Definition + Explanation + Examples)
What is a Variable?
A variable is a container that stores data in memory while the program is running.
Think of a variable like a box with a label:
The label = variable name
What you put inside the box = value
The type of box = data type
Example
int age = 25;
string name = "Sandhiya";
Here:
ageis a variable that stores an integer.namestores a string (text).
Key Points About Variables
Must have a data type
Example:
int number;
Must have a name
Example:
string fullName;
Can store a value
Example:
double price = 10.5;
Value can change
Example
int count = 1; count = 5;
Real-Time Example (Easy to Understand)
Imagine booking a movie ticket website.
Your Age → int variable
Your Name → string variable
Ticket cost → double variable
Is the payment successful? → bool variable
Example
string customerName = "Sandhiya";
int customerAge = 23;
double ticketPrice = 150.50;
bool isPaymentDone = true;
2. DATA TYPES (Definition + Uses + Examples)
What is a Data Type?
A data type tells C# what kind of value a variable can store.
Example
int age = 22;
int tells the computer:
"This variable will store whole numbers."
C# Data Types Fully Explained
A. Primitive (Basic) Data Types
1. int (Integer)
Stores whole numbers (no decimals)
int salary = 30000;
2. double (Decimal numbers)
Stores numbers with decimals
double rating = 4.5;
3. float (Decimal, smaller precision)
Ends with f
float temperature = 36.6f;
4. decimal (Money values — highest accuracy)
Ends with m
decimal productPrice = 999.75m;
Used for payment apps, billing systems, e-commerce
(because money requires accuracy)
5. char (Single character)
Must be single quotes ' '
char grade = 'A';

Join the conversation! Your thoughts help the community grow.