How to Edit a DateTime Variable During Visual Studio 2013 Debug Session

Viewed 2845

If I place a breakpoint and cause code execution to pause on a line where I wish to test the value of a DateTime variable, the Visual Studio 2013 debugger will display the value of my DateTime variable in the form "{10/1/2017 12:00:00 AM}" when I hover it and even allow me to begin to edit it--but when I press Enter I get the error, "Invalid expression term '{'". What is the proper way to edit a DateTime variable on the fly during a debug session?

3 Answers

Where the DateTime is a property of another object, it's possible to set the value using the Immediate Window. In the example command is a generic type parameter passed to a method so needs to be cast to the correct type before the property is accessible:

(command as SomeCommandWithDateTimeProp).ToDate = System.DateTime.Parse("2021-10-12")
Related