Declare Date type variable property as Nullable

Posted by Virendradugar under VB.NET category on | Views : 5212
See below given code to declare Nullable type date property. As sometimes it is required to insert null values in Date-Time type fields in database. If not used of nullable type, then developer has to handle it explicitly.

Dim _startdate As System.Nullable(Of Date)

Public Property StartDate() As System.Nullable(Of Date)
Return _startdate
End Get
Set(ByVal value As System.Nullable(Of Date))
_startdate = value
End Set
End Property

You can also declare Int as Nullable type.

Comments or Responses

Login to post response