Nullable
types was introduced in .NET 3.X. Assume i have DB table with column of type datetime
that accepts null
values. If the column data suppose to come from a windows forms client, How do i created a property of type datetime
and make it accept null
so i can send null
values to my DB table column? How this was done in prior versions of .NEt?
Nullable types was introduced in .NET 3.X
No, they were introduced in .NET 2.0. See the documentation.
How do i created a property of type datetime and make it accept null so i can send null values to my DB table column?
You couldn't. Typically people used a magic value of DateTime.MinValue
to represent null, and then made sure that their object/database translation layer converted that to a SQL null appropriately. An alternative was to have a separate bool
property to indicate the presence of a "real" value - or a separate type like SqlDateTime
.
See more on this question at Stackoverflow