string dt = "10/25/2010 11:40:05 PM";
var currentThread = Thread.CurrentThread.CurrentCulture; //ru-RU
DateTime dateTime = DateTime.Parse(dt); //Exception!
How to parse that dt?
UPDATE:
In my case DateTime can be represent as "25.10.2010 11:40:05" or "10/25/2010 11:40:05 PM"
Is these any “generic” method to parse it without changing CurrentCulture?
Use a custom Date and Time format string, using either
ParseExactorTryParseExact.The string cannot be parsed as a Russian
DateTimerepresentation since the Russian culture doesn’t use AM/PM, hence the use of the use ofCultureInfo.InvariantCulturewhich is a US like culture (it represents no specific culture, but is modeled after the en-US one).