Testing for null and something else on the same line of code
<p>I have a user object and I have a variable named userID.</p>

<p>I would like to test 2 things:</p>

<ul>
<li>user == null</li>
<li>user.UserID != userID</li>
</ul>

<p>The second test must be done only if user is not null otherwise I have a runtime error.</p>

<p>I wonder if it is possible to test both on the same line, something like below:</p>

<pre><code>return ((user == null) &amp;&amp; (user.UserID != userID))
</code></pre>

<p>But coded like above doesn't work because when user is null I have a runtime error.</p>

<p>Thanks.</p>
