Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to step out of foreach loop in debug mode

I have a method which I am interested to see it’s functionality and dig deeper; so I put a breakpoint and I stepped in the method. This method executes foreach loop along the way and this foeach keeps iterating many times. I am not interested in seeing the iteration going on in foreach loop. Is there a way in Visual Studio I can step out of this loop and continue debugging.

like image 265
Coder221 Avatar asked Feb 18 '16 16:02

Coder221


People also ask

How do I get out of loop while debugging?

Pressing ctrl+R is the correct option but if your break point is on a line which is inside the for loop, then you will have to first remove the break point and then press ctrl+R on the line on which you want the control to land. I faced this issue while debugging.

Is running in debug mode slower?

Unfortunately, debugger speed has some runtime limitations, which can't be easily fixed. If your code does some high performance computations, Debugger will be at least 3 times slower than usual Run.

Why is foreach forward only?

That is because foreach is meant to iterate over a container, making sure each item is visited exactly once, without changing the container, to avoid nasty side effects.


1 Answers

Right-click on a line after the loop, then click Run to cursor.

like image 165
SLaks Avatar answered Sep 27 '22 23:09

SLaks