I am using .net 4.0. I have interface with date time fields like
DateTime FromDate
{
get;
set;
}
DateTime ToDate
{
get;
set;
}
I want to set the value to this to null in my user interface like
IUser m_user = new User();
m_user.FromDate = DBNull.value;
In shows error , like cannot convert null to datetime.
How to assign null to datetime?
Thanks ,
pooja
You can’t do that, as DateTime can’t get
nullvalue because it’s value type.One way is changing your code to use Nullable type instead:
Then it can be null: