I am sending datetime to a function like:
MyFunction((DateTime)MethodDateTime);
Whereas my MethodDateTime is of DateTime datatype and contains null value.
Because of this while executing, it gives me error nullable object must have a value.
My Functions is this:
MyFunction(DateTime abc)
{
// Statements
}
So after surfing, what i can understand that i am forcing null to datetime. But this is my issue, sometimes i get null value as datetime, so how to deal with it?
Also when i am passing datetime directly it says
The best overloaded method match for 'Big.Classes.QStr.MyFunction(System.DateTime)' has some invalid argumentscannot convert from 'System.DateTime?' to 'System.DateTime'
So because of this i am doing (DateTime)MethodDateTime
Declaration and Initialization for my datetime is DateTime? MethodDateTime = null;
EDIT:
Major declaration i have made is:
/// <summary>
/// Get's or set's the MethodDateTime. If no MethodDateTime is there, this
/// attribute is null.
/// </summary>
DateTime? MethodDateTime
{
get;
set;
}