DateTime.ParseExact

Development Comments

If you're using DateTime.ParseExact with a custom format string including slashes, don't forget to escape them.

After I've catched FormatExceptions several times, I've found this explanation:

'/' is the default date separator defined in DateTimeFormatInfo.DateSeparator.  Therefore you have to escape '/' with '\' if you want to use it:

System.DateTime.ParseExact("2004/05/31 16:19:43", @"yyyy\/MM\/dd HH:mm:ss", null);

Comments