CSharp_Operators_Control_Constructors
CSharp_Operators_Control_Constructors
Operators are special symbols that perform operations on variables and values. Expressions are
1. Arithmetic Operators:
- +, -, *, /, %, ++, --
3. Logical Operators:
4. Assignment Operators:
- Example: x += 5; // same as x = x + 5
5. Bitwise Operators:
Expressions:
1. if Statement:
- Example:
2. if-else Statement:
- Example:
3. else-if Ladder:
- Example:
else Console.WriteLine("B");
4. switch Statement:
- Syntax:
switch (grade)
Constructors:
Types of Constructors:
1. Default Constructor:
- No parameters.
- Example:
2. Parameterized Constructor:
- Takes arguments.
- Example:
- Example:
4. Static Constructor:
- No access modifier.
- Example:
Destructors:
- Syntax: ~ClassName()
- Example:
Note: In C#, destructors are rarely needed due to automatic memory management.