1

Visual Studio supports us to debug line by line or jump straight to anywhere with break point. But for example,

for (int i = 0; i < 100000; i++)
    {
        //DO SOMETHING HERE
    }

How can I jump immediately to 500th loop? The fastest I have found so far was set break point at the begin of the loop and press F5 for multiple times.

I'm using Visual Studio 2019.

  • 1
    Possible duplicate of [How to set conditional breakpoints in Visual Studio?](https://stackoverflow.com/questions/6670415/how-to-set-conditional-breakpoints-in-visual-studio) – KUTlime Nov 24 '19 at 10:42

1 Answers1

1

You are looking for a conditional breakpoint that has been already covered few times on StackOverflow.

Here is answer for your loop-specific problem:

  1. Click on the gear button...

Breakpoint setup

  1. Setup your condition

Write down your condition.

Another possible solution

for (int i = 0; i < 100000; i++)
{
    #if DEBUG
        if( i == 500)
        {
            System.Diagnostics.Debugger.Break();
        }
    #endif
}
KUTlime
  • 5,889
  • 1
  • 18
  • 29