title: Why am I allowed to compare a non-nullable type with null?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1972262/c-okay-with-comparing-value-types-to-null">C# okay with comparing value types to null</a>  </p>
  </blockquote>
  
  
  
  <p>If I try to assign <code>null</code> to a non-nullable type in C#:</p>
  
  <pre><code>System.DateTime time = null;
  </code></pre>
  
  <p>I'll get a compile-time error:</p>
  
  <blockquote>
    <p>error CS0037: Cannot convert null to 'System.DateTime' because it is a non-nullable value type</p>
  </blockquote>
  
  <p>which makes sense. But if compare the same type against <code>null</code>:</p>
  
  <pre><code>System.DateTime time = obtainFromSomewhere();
  if( time == null ) {
      //whatever;
  }
  </code></pre>
  
  <p>there's no compile-time error. This doesn't make sense to me - if I can't assign <code>null</code> then why would it ever be <code>null</code>?</p>
  
  <p>Why am I allowed to compare a non-nullable type with <code>null</code>?</p>