When working in Visual Studio 2005/2008/2010/1012/2013 the dates and times are shown in mm/dd/yyyy hh:MM:ss format. Is there a way to change it to the same settings as the c
In "Control Panel\All Control Panel Items\Region and Language", on the "Formats" tab, click "Additional settings..." button. Visual Studio 2008 debugger formats dates using "Short date:" from the "Date" tab of "Customize Format".
Customize Format
QuickWatch
Considering only the .ToString() is affected, are you sure that
Thread.CurrentThread.CurrentCulture
is not being overridden or defaulted to something different than Swedish culture?
This behavior is built-in to the debugger, in the specific case that it is debugging a program written in VB.NET. Visible from the appearance of #
in the screenshot. Nothing terribly unusual, the debugger in many cases makes an effort to make its output the same as the way you would have written it in a program. Take C# for example, a string that contains embedded double-quotes will be displayed with backslashes before them. Not actually present in the string, but necessary when you declare such a string literal in source code.
So VB.NET language rules apply for the format of the literal string you see. Described in chapter 2.4.6 of the Language Specification, it is not culture sensitive. It of course can't be, your source code isn't going to produce a different program when your colleague in China compiles it. I'll just copy/paste the production rules:
DateLiteral ::= # [ Whitespace+ ] DateOrTime [ Whitespace+ ] #
DateOrTime ::=
DateValue Whitespace+ TimeValue |
DateValue |
TimeValue
DateValue ::=
MonthValue / DayValue / YearValue |
MonthValue – DayValue - YearValue
TimeValue ::=
HourValue : MinuteValue [ : SecondValue ] [ WhiteSpace+ ] [ AMPM ] |
HourValue [ WhiteSpace+ ] AMPM
MonthValue ::= IntLiteral
DayValue ::= IntLiteral
YearValue ::= IntLiteral
HourValue ::= IntLiteral
MinuteValue ::= IntLiteral
SecondValue ::= IntLiteral
AMPM ::= AM | PM
So it is always month/day/year. If you need to see the way it looks when you convert it to a string then you have to use the appropriate string conversion in your watch expression. Like CStr(Date.Now)
etcetera, beware there are many ways to do it since DateTime.ToString() can take formatting characters.