object reference null check issue, why not if? but try-catch block?
Posted on 2011-09-29
In my C# application, I want to check whether the object reference is null or not by;
if(myobj == null)
but C# doesn't let me do so, want me to surround the block with try-catch in runtime for that null value, but i am checking anyways, why is like that?
Isn't there a way to use if check for this?
In C, I was doing like that. It was a problem. In Java, I don't remember.
Could you inform me regarding C# and Java perspective?