Setting Breakpoints for Variables

  • Thread starter Thread starter Mortimer Schnurd
  • Start date Start date
M

Mortimer Schnurd

Hi folks,
I am just learning C# and need some help with setting debugger
breakpoints. In VB 6, I could easily set breakpoints on variables
which either change in value or evaluate to a specific value. It
appears C# does not allow you to do this (at least not easily). This
functionality was extremely useful in many instances of VB 6
debugging.

Is there some way in which I can emulate this same functionality in
C#? I've tried various methods including throwing an exception base on
an evaluation of a variable. This does allow the program to break into
debugger at that point but does not allow you to continue.

Any guidance would be appreciated.
 
Are you looking for:

Trace.Assert (from System.Diagnostics) as in:

private void button1_Click(object sender, System.EventArgs e)
{
int iVar = 4;
Trace.Assert(iVar > 4, "This integer is less than five");
}
 
You might also be refering to break point properties....

Set a break point....then right click on the line and select break
point properties......

Dave
 
You might also be refering to break point properties....

Set a break point....then right click on the line and select break
point properties......

Dave
You are correct, I am referring to the Breakpoint properties. However,
prior to reading your message. the procedure I used to establish the
breakpoint and set a condition was wrong (but C# complained in a way
which did not make that obvious).

I had double-clicked a variable to highlight it, then clicked on the
Debug, Insert Breakpoint menu-item. This had forced the variable name
to be the function name for the breakpoint. Trying to set a condition
then resulted in a warning message saying C# does not have that
ability to set breakpoint conditions on variables.

After reading your message, I went back and set a breakpoint at the
function start and was then able to bring up the breakpoint properties
and set a condition for a variable.

Thanks for your help, Dave.
 
Back
Top