Datetime.ParseExact "String was not recognized as a valid DateTime error"

Why can't I parse this line:

DateTime date = DateTime.ParseExact("‎23.‎02.‎2016 08:59:35", "dd.MM.yyyy HH:mm:ss", CultureInfo.InvariantCulture); 

Throws an exception

The string was not recognized as a valid DateTime.

I really do not understand.

+7
c # datetime
source share
1 answer

Your lines have zero width Unicode characters. If you delete them, it will work:

 DateTime.ParseExact("23.02.2016 08:59:35", "dd.MM.yyyy HH:mm:ss", CultureInfo.InvariantCulture) 
+8
source share

All Articles