Tuesday, 20 August 2013

TryParseExact returns false, though I don't know why

TryParseExact returns false, though I don't know why

This "TryParseExact" method returns true.
I would like to know why.
I think this date "2013.03.12" is invalid because this is not separated by
slash but dot.
After I changed the CultureInfo "de-De" to "en-US", the method returns
false. This could be a hint but I still don't know why this happens.
var format = new string[] { "yyyy/MM/dd" };
var parsed = new DateTime();
var result = DateTime.TryParseExact("2013.03.12", format,
new CultureInfo("de-DE"), DateTimeStyles.None, out parsed);

No comments:

Post a Comment