Convert String to Nullable DateTime
c#, datetime, nullable
Solution
You can try this:-
DateTime? dt = string.IsNullOrEmpty(date) ? (DateTime?)null : DateTime.Parse(date);
Problem
Possible Duplicate: How do I use DateTime.TryParse with a Nullable<DateTime>? I have this line of code ``` DateTime? dt = Condition == true ? (DateTime?)Convert.ToDateTime(stringDate) : null; ``` Is this the correct way to convert string to Nullable DateTime, or is there a direct method to convert without converting it to DateTime and again casting it to Nullable DateTime?