Reputation: 10871
I would like to be able to skip over certain parts of my code when I set breakpoints. For example, I have a code block which iterates 52 times to create a deck of cards. This is working properly and I would rather not have to hit F11 to keep stepping through that block. Is there anyway for me to "skip" this so that the debugger just goes on to the next method call?
Language and IDE is C# in VS 2008.
Upvotes: 3
Views: 761
Reputation: 8389
If it is an option, you could move that code into a function and apply the [DebuggerStepThrough] attribute to the function so that it will always be skipped during debugging
Like so:
using System.Diagnostics;
namespace MyNamespace
{
public class Utilities
{
[DebuggerStepThrough]
public ThisIsAVeryLongMethod()
{
//
// Code
//
}
}
}
Now in your code, when you step through, the debugger will not go to the method and just proceed to the next line
ShortMethod1();
ThisIsAVeryLongMethod();
ShortMethod2();
Upvotes: 2
Reputation: 7317
I don't know of any way to skip a block, but you can put a breakpoint after the block or use run-to-cursor (ctrl-F10, I think).
Upvotes: 2
Reputation: 55172
Set another break point where you want to end up, and press F5 :)
Upvotes: 5
Reputation: 755457
Do the following
This will do the equivalent of setting a breakpoint at that line, run the code as if you hit F5 and then delete the break point once it's hit.
Note: If the execution of the loop code hits another, real, breakpoint the execution will stop there and not where you clicked. If you think this may happen simply disable all breakpoints, do the trick above and re-enable all breakpoints.
Upvotes: 5