When a user is viewing the content in french I set the culture like:
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-CA");
And when in english I set it as:
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-CA");
Now dates are stored in en-CA format so I explicity always format using:
var dateFormatPattern = "M/d/yyyy"; // "MM/dd/yyyy"
var dt = DateTime.MinValue;
if (DateTime.TryParseExact(dateString, dateFormatPattern, null, System.Globalization.DateTimeStyles.None, out dtResult))
{
dt = dtResult;
}
Now it works in english, but when in french mode, the parse fails.
When in debug mode, I can see the value of dateString is the same in both french and english, but could it be the IDE changing the format? Since it is a string value, I don't think it could.
Then why is it failing?