NULL value for DateTime
For normal DateTimes, if you don’t initialize them at all then they will match DateTime.MinValue, because it is a value type rather than a reference type.
You can also use a nullable DateTime, like this:
DateTime? MyNullableDate;
Or longer version:
Nullable MyNullableDate;
And, finally, there’s a built in way to reference the default of any type. This returns null for reference types, but for our DateTime example it will return the same as DateTime.MinValue:
default(DateTime)
or, in more recent versions of C#,
default
And you can check the value with:
if (dt.HasValue)
{
// Do something with dt.Value
}
Or you can use it like:
DateTime dt2 = dt ?? DateTime.MinValue;
You can read more here:
http://msdn.microsoft.com/en-us/library/b3h38hb0.aspx