문제

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.

도움이 되었습니까?

해결책

Replace CultureInfo.InvariantCulture with null.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top