if (date2 == "")
{
date2 = null;
}
DateTime dates2 = DateTime.ParseExact(date2, "dd-MM-yyyy H:mm", CultureInfo.InvariantCulture);
by using this code i got an Error 'String reference not set to an instance of a String.'.


Ehsan SajjadRank #512 · 4.8K reputationPosted Jun 25, 2016, 4:30 PM EDT
Francis SusaimichaelRank #466 · 5.4K reputationPosted Jun 24, 2016, 10:57 PM EDT
DateTime? dt ;
Rafnas T PRank #280 · 8.8K reputationPosted Jun 25, 2016, 3:06 AM EDT
Vinay SinghRank #604 · 4K reputationPosted Jun 25, 2016, 9:45 PM EDT
Try the below link
Since DateTime is a value type you cannot assign null to it, but exactly for these cases (absence of a value) Nullable