DateTime is a value type. If you try to assign null value to DateTime it will throw compile time error "Cannot convert null to System.DateTime because it is a non-nullable value type."
DateTime has the default value that is equal to the DateTime.MinValue. You can assign this to DateTime.
In C# 2.0, Microsoft introduced "Nullable Types" using the nullable operator (?). It will allow you to assign the null values to the value types. So we can assgin a null value to the DateTime by making it as Nullable Type.
No comments:
Post a Comment