C# “if (object && otherObject)” did not produce an error

So I accidentally coded in human, thinking in my head I could do

if (object && otherObject == null)

to check if both objects are null. Obviously not how C# works, but it did not produce an error. I did a bit of a test and I'm assuming that it is checking

"if (object != null)" when doing "if (object)" and "if (object == null)" when "if (!object)"

Which is something I never learned, and just wanted to 1. Make sure that's what it is doing and 2. Share for those who don't know

submitted by /u/PhantomThiefJoker
[link] [comments]

from Software Development – methodologies, techniques, and tools. Covering Agile, RUP, Waterfall + more! https://ift.tt/2rWwBi2

Leave a comment

Design a site like this with WordPress.com
Get started
search previous next tag category expand menu location phone mail time cart zoom edit close