Replace CultureInfo.InvariantCulture
with null
.
Need some advice on dates and culture
题
We have some legacy code that can't really be altered which "forces" the user to enter a date in MM/dd/yyyy format through ValidationExpression and a regex on the text field.
However, the C# code will be expecting the date in either MM/dd/yyyy or dd/MM/yyyy depending on the region.
I need to format the entered date into the region specific date.
Any ideas?
So far I've tried DateTime enteredDate = DateTime.ParseExact(StartDateTextBox.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture);
but that returns as error stating that "09/04/2013" is not a recognised date.
解决方案
不隶属于 StackOverflow