Tuesday, April 28, 2015

assigning Null value to datetime in C#

Since DateTime is a value type (like int), a Null value cannot be assigned to it.

DateTime? dateSample;
dateSample.Value = null;
//or 
Nullable<DateTime> dateSample2;
dateSample2.Value = null;

No comments:

Post a Comment