Using C#. I have a string dateTimeEnd.
dateTimeEnd
If the string is in right format, I wish to generate a DateTime and assign it to eventCustom.DateTimeEnd
DateTime
This should work:
if (!string.IsNullOrWhiteSpace(dateTimeEnd)) eventCustom.DateTimeEnd = DateTime.Parse(dateTimeEnd); else eventCustom.DateTimeEnd = null;
Note that this will throw an exception if the string is not in the correct format.