title: VB.NET - Nullable DateTime and Ternary Operator
body: <p>I'm having problems with a Nullable DateTime in VB.NET (VS 2010).</p>
  
  <p>Method 1</p>
  
  <pre><code>If String.IsNullOrEmpty(LastCalibrationDateTextBox.Text) Then
      gauge.LastCalibrationDate = Nothing
  Else
      gauge.LastCalibrationDate = DateTime.Parse(LastCalibrationDateTextBox.Text)
  End If
  </code></pre>
  
  <p>Method 2</p>
  
  <pre><code>gauge.LastCalibrationDate = If(String.IsNullOrEmpty(LastCalibrationDateTextBox.Text), Nothing, DateTime.Parse(LastCalibrationDateTextBox.Text))
  </code></pre>
  
  <p>When given an empty string Method 1 assigns a Null (Nothing) value to gauge.LastCalibrationDate but Method 2 assigns it the DateTime.MinValue.</p>
  
  <p>In other places in my code I have:</p>
  
  <pre><code>LastCalibrationDate = If(IsDBNull(dr("LastCalibrationDate")), Nothing, dr("LastCalibrationDate"))
  </code></pre>
  
  <p>This correctly assigns Null (Nothing) from a Ternary Operator to a Nullable DateTime.</p>
  
  <p>What am I missing?  Thanks!</p>