What is wrong with DateTime.Parse(myString)?

c#, datetime

Solution

In addition the locale problem, `DateTime.Parse()` could also throw an exception which you would then have to catch. Use `DateTime.TryParse()` or `DateTime.TryParseExact()` instead.

Problem

I was browsing Scott Hanselman's Developer Interview question list, and ran across this question: What is wrong with DateTime.Parse(myString)? While I know there are inherent risks in parsing a string of unknow format or origin, are there other reasons? Is it to use DateTime.ParseExact instead? Should it be myString.ToString() first?

Original source