title: How can I throw an Exception with a certain HResult?
body: <p>I want to test the following code:</p>
  
  <pre><code>private bool TestException(Exception ex)
  {
      if ((Marshal.GetHRForException(ex) &amp; 0xFFFF) == 0x4005)
      {
          return true;
      }
      return false;
  }
  </code></pre>
  
  <p>I'd like to set up the <code>Exception</code> object somehow to return the correct HResult, but I can't see a field in the <code>Exception</code> class which allows this.</p>
  
  <p>How would I do this?</p>