Basic
Basic
In C#, variables store data and are associated with a specific type. They can be:
Value Types: Store actual data (e.g., int, double, bool, char, struct).
Reference Types: Store references to memory locations (e.g., string, class, object,
array).
Declaration Example:
Constants (const): Values that never change during the program's execution. Must be
initialized at the time of declaration.
Read-only Fields (readonly): Values assigned either at the time of declaration or in the constructor but
cannot be changed afterward.
class Example {
public Example() {
}
3. Type Casting and Conversion
4. Operators
Arithmetic Operators
Logical Operators
if Statement
} else {
switch Statement
int day = 3;
switch (day) {
case 1:
Console.WriteLine("Monday");
break;
case 2:
Console.WriteLine("Tuesday");
break;
case 3:
Console.WriteLine("Wednesday");
break;
default:
Console.WriteLine("Other day");
break;
Loops
For Loop:
While Loop:
int counter = 0;
counter++;
Do-While Loop:
int count = 0;
do {
count++;