This is the case. I get the date from DatePicker control:
DateTime current = datePicker1.SelectedDate;
And I get an error: Cannot implicitly convert DateTime? to DateTime. So I guess it's up to a nullable type DateTime?.
Is it safe to cast this type to a type I need like this:
if (datePicker1.SelectedDate == null)
current= DateTime.Now;
else
current= (DateTime)datePicker1.SelectedDate; //or datePicker1.SelectedDate.Value
And in general, when is it SAFE to implicitly cast nullable values, and when it isn't?