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 SajjadPosted Jun 25, 2016, 8:30 PM
Vinay SinghPosted Jun 26, 2016, 1:45 AM
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
Rafnas T PPosted Jun 25, 2016, 7:06 AM
Francis SusaimichaelPosted Jun 25, 2016, 2:57 AM
DateTime? dt ;