Reputation: 5725
Is there is a tool or a setting in the Visual Studio debugger to stop on breakpoints or when a variable is set to a particular value? I mean, if I know that value will be set to "HELLO," I want the debugger will stop the same way it would if it reached a breakpoint?
Upvotes: 4
Views: 2368
Reputation: 361
try - System.Diagnostics.Debug.Assert(yourVariable <> "HELLO")
and then click on 'Cancel' button to start debugging. This works for ASP.net and Silverlight projects
Upvotes: 0
Reputation: 900
Daves answer.
And I'll add that you can just add a if statement that contains a couple of dummy statements and you put a breakpoint inside it. It does the same thing.
Typical use :
if (i == 250) {
int dummy = 2+2; //breakpoint here
}
In your case, since you watch the value of a string (assuming C++ strings)
if (mystring == "hello")
{
int dummy = 2+2; //breakpoint here
}
Upvotes: 3
Reputation: 347566
The breakpoint will be hit when the condition is met.
Via the right click on breakpoints menu, you can also set breakpoints:
Upvotes: 8