1.
Variables (Different Types)
Definition: Variables store data values, and in C#, you must declare them with a
specific data type. The data type determines what kind of values the variable can
hold.
Common Variable Types:
int: Stores whole numbers (e.g., 1, -5, 10)
double or float: Stores decimal numbers (e.g., 3.14, -0.001)
string: Stores text (e.g., "Hello", "123")
char: Stores a single character (e.g., 'a', '1')
bool: Stores true or false (e.g., true, false)
int age = 25; // Integer variable
double price = 19.99; // Decimal variable
string name = "John"; // String variable
char grade = 'A'; // Character variable
bool isStudent = true; // Boolean variable
When to use:
Use int when working with whole numbers (count, index, etc.).
Use double or float for fractional numbers (prices, measurements).
Use string for text data.
Use bool for true/false values.