title: How to check if DateTime object was not assigned?
body: <p>So, First of all. Code: 
  I've got a class: </p>
  
  <pre><code>public class Myobject
  {
      public string Code { get; set; }
      public DateTime? StartDate { get; set; }
  }
  </code></pre>
  
  <p>And this is part of very simple source:</p>
  
  <pre><code>MyObject mo = new MyObject();
  mo.Code= "sth";
  // NO action on StartDate property! 
  
      if (mo.StartDate.HasValue)
      {
          sc.Parameters.Add(new SqlParameter("@inStartDate", mo.StartDate.Value));
      }
      else
      {
          sc.Parameters.Add(new SqlParameter("@inStartDate", DBNull.Value));
      }
  </code></pre>
  
  <p>Simple 'if' - Sql Server 2008, throw an error - when gets null Datetime (it has to be DBNull.Value)
  So I want to check it first, and then pass right value or DBNull. </p>
  
  <p>My problem is - this 'if' always retruns true! Why!? </p>
  
  <p>Also tried that: </p>
  
  <pre><code>if (mo.StartDate.Value == null)
  </code></pre>
  
  <p>but it always returns false. How come it is not a null? It was not even created..</p>
  
  <p>So.. <strong>How to check if DateTime object was not assigned?</strong></p>