VB.NET'te (VS 2010) Nullable DateTime ile ilgili sorunları yaşıyorum.VB.NET - Null'lu DateTime ve Üçlü Operatör
Yöntem 1
If String.IsNullOrEmpty(LastCalibrationDateTextBox.Text) Then
gauge.LastCalibrationDate = Nothing
Else
gauge.LastCalibrationDate = DateTime.Parse(LastCalibrationDateTextBox.Text)
End If
Yöntem 2
gauge.LastCalibrationDate = If(String.IsNullOrEmpty(LastCalibrationDateTextBox.Text), Nothing, DateTime.Parse(LastCalibrationDateTextBox.Text))
Yöntem 1 gauge.LastCalibrationDate bir boş (şey) bir değer atar ancak Yöntem 2 DateTime.MaxValue'dan atar boş bir dizge zaman. Benim kodunda başka yerlerde
Ben:
LastCalibrationDate = If(IsDBNull(dr("LastCalibrationDate")), Nothing, dr("LastCalibrationDate"))
Bu doğru bir null DateTime için bir Üçlü Operatörü dan Null (Nothing) atar.
Neyi eksik? Teşekkürler!
+1 İstenen sonucu üretecek geçici çözümü ekleyerek güzel iş. –