What\'s the difference between or and OrElse?
if temp is dbnull.value or temp = 0
produces the error:
(I've looked at other answers and realized I was terribly wrong)
The OrElse operator "performs short-circuiting logical disjunction on two expressions", that is to say: if the left operand is true and so the entire expression is guaranteed to be true the right operand won't even be evaluated (this is useful in cases like:
string a;
//...
if (a is null) or (a = "Hi") //...
to avoid a NullReferenceException throw by the right-hand operand.
I'm sincerely astonished that this (lazy evaluation) isn't the default behaviour of or
and and
as it is in C/C++ and C# (and many other languages...)