ive have type casting issue and i need help as soon as possible :D, now the issue is ive methods to check nullable values for datetime and int types… but im getting type cast error…
method :
public static DateTime? ToNullableDateTime(string stringValue)
{
DateTime dateValue;
if (DateTime.TryParse(stringValue, out dateValue)) { return dateValue; }
else { return DateTime.MinValue; }
}
using the method its in my object class :
Objects<DateTime?>.ToNullableDateTime(((Label)gvRow.FindControl("lblCommitmentDate")).Text);
Error :
Cannot implicitly convert type ‘System.DateTime?’ to ‘System.DateTime’. An explicit conversion exists (are you missing a cast?)
You’re defining a return type of
DateTime?and trying to return aDateTime.