How do I set a null value for an optional DateTime parameter in a constructor?
I’m using the following constructor below and I want the optional parameter admissionDate to be a null DateTime. Setting it to Nothing actually gives it a value (something like #12:00:00 #).
Public Sub New(ByVal obj1 as Object, Optional ByVal admissionDate As DateTime = System.Data.SqlTypes.SqlDateTime.Null)
I’d suggest using James Curran’s solution but use Overloading instead of an optional parameter, as a workaround for the error you mentioned (‘Optional parameters cannot have structure types’) :
You can also use DateTime? instead of Nullable(Of DateTime) in the latest version of VB (not sure about the older versions).