Debuuger Stop or break?

E

Eric Kiernan

i'd like to stop and break into debugging mode if a certain condition is
true. I have a line counter ( i'm reading a text file ), and I want
it to break at a certain line of the textfile. so i'd like to say
something like if ( lineCntr == 141) {
break;

documentation seems confusing.
 
J

Jeff Johnson

i'd like to stop and break into debugging mode if a certain condition is
true. I have a line counter ( i'm reading a text file ), and I want it to
break at a certain line of the textfile. so i'd like to say something
like if ( lineCntr == 141) {
break;

documentation seems confusing.

Set a breakpoint. Then right-click the red circle breakpoint symbol and
check out the options on the context menu.

You're going to have to maintain the line count yourself in a variable, of
course. If that's what lineCntr is, then you're golden.
 
M

Morten Wennevik [C# MVP]

Hi Eric,

In addition to using breakpoint conditions you can programmatically break at
any point in your code.

if (DateTime.Now.DayOfWeek == DayOfWeek.Thursday)
System.Diagnostics.Debugger.Break();

Usually the conditions are simple enough to put on the breakpoint itself,
though.
 
E

Eric Kiernan

That is very good to know. With both tools for breaking, i feel much
better ( I know the first one works ), and i'll soon test the second.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top