Variable
Variable
Example:
int i, j;
double d;
float f;
char ch;
string s;
If you don't want others (or yourself) to overwrite existing values, you
can add the const keyword in front of the variable type.
The WriteLine() method is often used to display variable values to the console
window.
Example:
string batch = "Batch2024";
Console.WriteLine("Hello " + batch);
string firstName = "John ";
string lastName = "Doe";
string fullName = firstName + lastName;
Console.WriteLine(fullName);
int x = 5;
int y = 6;
Console.WriteLine(x + y);
Declare Many Variables
➔ int x = 5, y = 6, z = 50;
Console.WriteLine(x + y + z);
➔ int x, y, z;
x = y = z = 50;
Console.WriteLine(x + y + z);