Invariant Cultures and Weird .NET Behaviour
IT Chapters August 25th, 2006I am a little confused after having some very strange issues formatting dates and strings with the CultureInfo.InvariantCulture today with one of our applications.
One of our methods tries to parse a string as a date:
DateTime.Parse(myStringDate, CultureInfo.InvariantCulture);
If I passed in ‘28/05/2006′ this would throw a format exception. Why?
Another extremely weird thing would be if I had formatted a date using CultureInfo.InvariantCulture and then passed that as a parameter to a SQL query, the query would eventually time out. Removing the InvariantCulture parameter and everything worked perfectly.
Very weird. Any ideas?