R
raylopez99
Beware this asymmetric relationship:
statement #1: if (X) {A} else {B}
statement #2: if (!X) {B} else {A}
where X returns a boolean and A,B are statements.
You'll find that it's possible when X changes state from true to false
that A and B will both fire in statement #1, but, in statement #2,
when X changes from false to true, neither B nor A will fire. This
could give problems if you require "A" to do something important in
statement #2, such as to clean up code or initialize it.
Just a quick newbie observation. It really has nothing to do with C#
per se however, just another logical trap like I noted in an earlier
post that logical and boolean operators are not symmetric either (i.e.
A && B != B&&A; A & B != B&A in conditional statements, as the order
of A,B is important).
RL
statement #1: if (X) {A} else {B}
statement #2: if (!X) {B} else {A}
where X returns a boolean and A,B are statements.
You'll find that it's possible when X changes state from true to false
that A and B will both fire in statement #1, but, in statement #2,
when X changes from false to true, neither B nor A will fire. This
could give problems if you require "A" to do something important in
statement #2, such as to clean up code or initialize it.
Just a quick newbie observation. It really has nothing to do with C#
per se however, just another logical trap like I noted in an earlier
post that logical and boolean operators are not symmetric either (i.e.
A && B != B&&A; A & B != B&A in conditional statements, as the order
of A,B is important).
RL