title: How should you test if a variable is a value type in C#?
body: <p>I have a few places where I have a generic type parameter that is not limited to class (or struct), and when I try to compare variables of that type against <code>null</code>, Resharper underlines it, complaining that I may be comparing a value type to <code>null</code> (a valid objection, to be sure). Is there an accepted way of checking if a variable is a value type before comparing against null?</p>
  
  <p>For example:</p>
  
  <pre><code>public TObject MyProperty { get; set; }
  
  ...
  private void SomeMethod()
  {
      if(MyProperty == null) //Warning here
      {
         ...
      }
  }
  </code></pre>
  
  <p>I've been doing <code>if(!(MyProperty is ValueType) &amp;&amp; MyProperty)</code>--is that valid? It doesn't get rid of the warning, but that doesn't necessarily mean anything.</p>