Is there a clever way to handle this null object reference?
<p>So I have a Retrieve() function, which either gets me an object or a null (if that object is not found). I'm using an if statement with a boolean attribute of that object. It's set up like this.</p>

<pre><code>if(Retrieve(index).IsForm == true) {}
</code></pre>

<p>The issue with this is that if it doesn't find an object, it'll throw a null reference exception. There are some ways around this, of course, but none that I find concise. There's a try...catch, but that seems pointless when I expect the error. I can check if the object is null first, <code>if(Retrieve(index) != null)</code>, but that seems like adding needless nesting. Is there a clever way to handle this? I thought of using the null coalescing operator but it doesn't work in this situation.</p>
