Dupe: Null Difference
A lifetime ago I came across an article that explained that the following were not equal (in c#):
if (o == null) {}
if (null == o) {}
The article explained that the latter was preferred because it resulted in a more accurate test. I've been coding like that ever since. Now that I understand so much more I was looking for the article, or another like it, to see what the exact findings were, but I can't find anything on the subject.
Thoughts? Is there a difference? First glance would say no. But who knows what happens in the bowels of IL and C# compilation.
it's an old habit to prevent you from typing if (o = null). if (null = o) is a syntax error. kind of pointless in C#, because null values aren't ever coerced into booleans.
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