如何在Visual Studio 2013调试会话期间编辑DateTime变量 [英] How to Edit a DateTime Variable During Visual Studio 2013 Debug Session
问题描述
如果我放置一个断点并导致代码执行在我要测试DateTime变量值的行上暂停,Visual Studio 2013调试器将以"{10/1"的形式显示我的DateTime变量的值/2017 12:00:00 AM}",当我将其悬停甚至允许我开始对其进行编辑时,但是当我按Enter键时,出现错误无效的表达式项'{'".在调试会话期间即时编辑DateTime变量的正确方法是什么?
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?
推荐答案
当执行暂停时,将鼠标悬停在DateTime变量上会弹出一个数据提示提示框.在其中单击日期以开始对其进行编辑.将弯曲的括号切换为引号,并通过调用DateTime.Parse将整个引用日期括起来,如下所示:
While execution is paused, a little datatip pop-up appears when you hover over your DateTime variable. Click the date within to begin editing it. Switch the squiggly parentheses to quotes, and surround the entire quoted date with a call to DateTime.Parse, like so:
DateTime.Parse("10/1/2017 12:00:00 AM")
然后您可以将报价内的日期更改为所需的任何新日期-当您按Enter键时,相应的DateTime值将即时插入变量中!
You can then change the date inside the quote to whatever new date you want--and when you press Enter, the corresponding DateTime value will be inserted into your variable on the fly!
这篇关于如何在Visual Studio 2013调试会话期间编辑DateTime变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!