title: How to set DateTime to null
body: <p>Using C#. I have a string <code>dateTimeEnd</code>.</p>
  
  <p>If the string is in right format, I wish to generate a <code>DateTime</code> and assign it to eventCustom.DateTimeEnd  of type</p>
  
  <pre><code>public Nullable&lt;System.DateTime&gt; DateTimeEnd { get; set; }
  </code></pre>
  
  <p>If <code>dateTimeEnd</code> is null or empty I need <code>eventCustom.DateTimeEnd</code> set to null.</p>
  
  <p>I am trying to achieve this using the following code but I get always null for <code>eventCustom.DateTimeEnd</code>.</p>
  
  <p>Could you please help me out to define what is wrong in my code?</p>
  
  <pre><code>   DateTime? dateTimeEndResult;
       if (!string.IsNullOrWhiteSpace(dateTimeEnd))
          dateTimeEndResult = DateTime.Parse(dateTimeEnd);
  
  
  eventCustom.DateTimeEnd = dateTimeEndResult = true ? (DateTime?)null : dateTimeEndResult;
  </code></pre>