title: Is there a way to have a C# class handle its own null reference exceptions
body: <p><strong>Question</strong></p>
  
  <p>I'd like to have a class that is able to handle a null reference of itself. How can I do this? Extension methods are the only way I can think to do this but thought I'd ask in case there was some nifty thing I didn't know about C#.</p>
  
  <p><strong>Example</strong></p>
  
  <p>I have a class called <code>User</code> with a property called <code>IsAuthorized</code>.</p>
  
  <p>When <code>User</code> is properly instantiated <code>IsAuthorized</code> has an implementation. However, when my <code>User</code> reference contains null  I'd like a call to <code>IsAuthorized</code> to return false instead of exploding.</p>
  
  <hr>
  
  <p><strong>Solution</strong></p>
  
  <p>Lot's of good answers. I ended up using three of them to solve my problem.</p>
  
  <ol>
  <li>I used the Null Object design pattern suggested by Zaid Masud.</li>
  <li>I combined that with Belmiris' suggestion of using struct so I couldn't have a null reference</li>
  <li>And got a great explanation for why C# works this way and how I could really solve it from Jon Hanna</li>
  </ol>
  
  <p>Unfortunately I can only pick one of these as my accepted answer so if you are visiting this page you should take the time to up vote all three of these and any of the other excellent answers that were given.</p>