I'm sure this question has probably been answered before, so I apologize, but I wasn't able to find the proper search terms to find the answer.
Given the following code example, does db.GetRecords().Any()
get executed?
string s = "Z";
bool x = s.IndexOfAny(new[] { 'A', 'B' }) > 0 &&
db.GetRecords().Any();
No. Both &&
and ||
are evaluated by short-circuit evaluation. This means that a && b
returns false if a
is false and a || b
returns true if a
is true and it will not evaluate b
in either of these cases.
If for some reason you do not want short-circuit evaluation you can use the bitwise operators &
and |
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With