Using C#. I have a string dateTimeEnd.
If the string is in right format, I wish to generate a DateTime and assign it to eventCustom.DateTimeEnd
This line:
eventCustom.DateTimeEnd = dateTimeEndResult = true ? (DateTime?)null : dateTimeEndResult;
is same as:
eventCustom.DateTimeEnd = dateTimeEndResult = (true ? (DateTime?)null : dateTimeEndResult);
because the conditional operator ? has a higher precedence than the assignment operator =. That's why you always get null for eventCustom.DateTimeEnd. (MSDN Ref)