What the.... How do I change the value of a DateTime in the debugger? I can change it, but I get an error when leaving the edit field; it cannot parse it.
Edit: VS 2008, C#
You can change the date in the Immediate Window.
date = new DateTime(2009, 10, 05)
{05/Oct/2009 12:00:00 AM}
Date: {05/Oct/2009 12:00:00 AM}
Day: 5
DayOfWeek: Monday
DayOfYear: 278
Hour: 0
Kind: Unspecified
Millisecond: 0
Minute: 0
Month: 10
Second: 0
Ticks: 633902976000000000
TimeOfDay: {00:00:00}
Year: 2009
We do can change a DateTime value directly in the Watch Window. The trick is simple: we always have to use a "new DateTime()" method, providing the appropriate parameters.
The Watch Window do not allow you to to type a new value directly, so things like "2010-07-13 9:15" or even {13/07/2010 09:00:00} don't work.
The "dt = " portion isn't strictly necessary. Just type in "dt.AddDays(3)" or "new DateTime(...)" or DateTime.Parse(""), etc, and the debugger will try to assign whatever value results from the expression you type to the variable under watch; it just so happens that because C# has assignment expressions (e.g. y = (x = 1); //sets y = 1) that assigning the expression to the variable name works. :)