Jak ustawić wartość nullable DateTime na null w VB.NET?

Próbuję ustawić filtr zakresu dat w moim interfejsie użytkownika, z polami wyboru, aby powiedzieć, czy wartość DateTimePicker powinna być używana, np.

Dim fromDate As DateTime? = If(fromDatePicker.Checked, fromDatePicker.Value, Nothing)

Jeszcze ustawieniefromDate doNothing nie powoduje ustawienia naNothing ale do „12: 00: 00 AM” i następującychIf instrukcja niepoprawnie wykonuje filtr, ponieważstartDate nie jestNothing.

If (Not startDate Is Nothing) Then
    list = list.Where(Function(i) i.InvDate.Value >= startDate.Value)
End If

Jak naprawdę zapewnićstartDate dostaje wartośćNothing?

questionAnswers(5)

yourAnswerToTheQuestion