Debugger execution steps

When you are debugging a code, you may want to debug it line-by-line. Thus, you will need to execute the current line and step over to next one. Sometimes you may want to go deep into the method or property to debug the code. You can do all these things from the Visual Studio Debug menu:

You can click the Debug | Step Over menu or press the keyboard shortcut F10 to execute the current line and jump into the next line for execution. Click the Debug | Step Into menu item or press the F11 key to step into any property or method for debugging. You can then continue the line by line execution by pressing F10 or continue executing the program to the end or to the next breakpoint by pressing the F5 key on the keyboard:

Visual Studio also provides some smart menu entries to help you in debugging your code. When you are at any breakpoint, you can continue the execution to a specific line and break again. To do so, right click on any line within that debugging context and choose Run to Cursor as shown in the preceding screenshot. Alternatively, you can click the desired line and press the keyboard shortcut Ctrl + F10 to continue the execution.

In this case, all the lines between the executing line and selected line will execute before it breaks. This is same as placing another breakpoint on that line:

You can also ask Visual Studio to jump into a specific line without executing certain lines of code. This is sometimes needed when you smell a bad code which is causing a bug to occur and you want to check without removing/commenting/changing that portion of code.

A point to remember is that Run To Cursor executes lines of code in between whereas Set Next Statement skips code in between.

While you are at a specific breakpoint, you can right click on any line within that debugging context and select Set Next Statement. You can also press the keyboard shortcut Ctrl + Shift + F10 to move the current marker of your debugger to that selected line. Alternatively, you can also drag the marker arrow of the current line to the new execution line to set it as the next statement. None of the code written within those two lines will execute during that debugging instance.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.88.249