Sunday, September 9, 2007

null == object || object == null

Is there any difference between them ?

My findings is there is no significance difference between them in case of C#,

But in case of C++ they have a very significant difference. If the above object have overloaded equals operator and if the second parameter does not filtered with NULL check then it will get NullReferenceException for the second expression. But in case of first expression it will not. The same error can be produces in JAVA with the help of method Equals. But the first one is always safe and I prefer this one.

No comments:

Post a Comment

Please, no abusive word, no spam.