Breakpoint on Field Change

  • Thread starter Thread starter Andrew Robinson
  • Start date Start date
A

Andrew Robinson

Give the following, is it possible to set a breakpoint in C# that fires when
the value of x changes. I want to see the line that is changing the field x.
Optionally, is it possible to fire a breakpoint when the value of x changes
to a specific value (ie x='hello').

thanks,

-Andrew

private string x = string.Empty;
private void button1_Click(object sender, System.EventArgs e)
{
x = "new value";
}
 
1. Add a break point to the line and open the break-point explorer
(Debug->Windows->Breakpoints)
2. Find the break point you added in the break point explorer, right
click select properties
3. In the break point properties you will find a button labelled
"Condition". Click that and the condition dialog will open
4. Enter the appropriate condition and select either "Is True" or "Has
Changed".
5. Close and debug.

Depending on which debug condition, if is true was specified then the
break point will hit only when the condition you entered evaluates to
true, and "Has Changed" option causes the breakpoint to hit if the
value has changed.

NuTcAsE
 
Back
Top