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?
In addition the locale problem,
DateTime.Parse()could also throw an exception which you would then have to catch. UseDateTime.TryParse()orDateTime.TryParseExact()instead.