Operators are symbols used to calculate values, compare them, and check conditions. Just like + and - on a calculator, operators are the workhorses of your program's logic.
csharp
int price = 100;
int quantity = 3;
int total = price * quantity;
bool hasDiscount = total >= 300;
Console.WriteLine($"Total: {total}");
Console.WriteLine($"Discount allowed: {hasDiscount}");What to notice in this code
*is the multiplication operator, multiplying price by quantity.>=is a comparison operator, checking whether total is greater than or equal to 300.- The comparison result is either
trueorfalse.
You should see
Total: 300 Discount allowed: TrueInfo
🔎 Operator groups
Arithmetic: + - * / %; Assignment: = += -=; Comparison: == != > < >= <=; Logical: && || !