I am getting issue while converting string to DateTime.
The value I am receiving as "08-26-2015 10:14:57.898Z".
I am trying to convert the above string to DateTime.
My Code:
DateTime.ParseExact(element.Value,"MM/dd/yyyy HH:mm:ss",CultureInfo.CurrentCulture);
Exception: String was not recognized as a valid DateTime.
/and not a dash-. As others have mentioned you might want to useDateTime.ParseorConvert.ToDateTimeinstead or specify that you want dashes as the separator in the format. Also you need to specify the milliseconds and the Z at the end.