Which one out of the following two should be preferred while doing && operation on two values.
if (!StartTime.Equals(DateTime.MinValue) &&
!CreationTime.Equals(DateTime.MinValue))
Or
if (!(StartTime.Equals(DateTime.MinValue) && CreationTime.Equals(DateTime.MinValue))
What is the difference between the two?
(Not A) AND (Not B)
is NOT equal to
Not (A And B)
Personally I use the former, I find it easier to read if as much information as possible is as close to the point I need it as possible.
For instance, just now I was wondering if your question was whether it was better to put the expression on two lines or just one, until I noticed the part about the not and the parenthesis.
That is, provided they mean the same, which your expressions doesn't.
ie.
if (!a && !b)
is not the same as:
if (!(a && b))
Rather:
if (!(a || b))
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