Hcabnettek
Hcabnettek

Reputation: 12928

Debugging Help - set a value in debug mode?

I am debugging and I hit my break point. I hover over a variable and I get the standard drilldown. I see a Nullable prop and it is null. I right click and choose "edit value". No matter what I seem to type, I get "The value could not be set. Please check your entry." I have tried 5/1/09, new DateTime(2009, 5, 1), {05/01/2009}... pretty much every flavor I could think of. What the heck am I doing wrong? I would like to code in the value and continue debugging with the new value.

Any suggestions?

Thanks, ~ck

Upvotes: 1

Views: 3213

Answers (5)

RichardOD
RichardOD

Reputation: 29157

Seems easy to me. I had this line:

    DateTime dt = DateTime.Parse("01/01/2000");

Hit the breakpoint, and typed this into the immediate window:

dt = DateTime.Parse("02/01/2010")

The same technique also works when editing the value in the debugger tooltip, the locals window, the autos window, the watch window and even the quick watch window.

Upvotes: 2

Steven Sudit
Steven Sudit

Reputation: 19630

Is this object a "DateTime" or a "Nullable" (which is the same as "DateTime?")?

Upvotes: 0

Austin Salonen
Austin Salonen

Reputation: 50235

In a Watch window line, type this in the name field:

dt = new DateTime(2009,5,1)

The line will be disabled so just delete it. In the next line, type in dt and it will be the value you want.

Upvotes: 0

Oren Trutner
Oren Trutner

Reputation: 24218

DateTime.Parse("5/1/2009")

Upvotes: 3

RiddlerDev
RiddlerDev

Reputation: 7479

Try using #5/1/2009#

Upvotes: 0

Related Questions