int biryani = 250;
int coke = 60;
double total = (biryani + coke) * 1.18; // 365.8 with GST
bool freeDelivery = total > 300; // true
+ - * / %
Math
== != > <
Compare
&& || !
AND OR NOT
All Operators Explained
Category
Operators
Example
Result
Arithmetic
+ - * / %
10 % 3
1 - remainder
Assignment
= += -= *=
x += 5
x = x + 5
Comparison
== != > < >= <=
5 >= 5
true
Logical
&& || !
true && false
false
Increment
++ --
x++
x = x + 1
Short-Circuit Evaluation
bool check() { Console.WriteLine("Called"); return false; }
if (false && check()) { } // check() never runs. && stops at first false
if (true || check()) { } // check() never runs. || stops at first true
Use this to prevent errors: if (user != null && user.IsActive)
No comments yet. Be the first to share your thoughts!