Navigating with the Debugger Toolbar and Debugging Windows
Explore how to use the debugger toolbar and debugging windows in Visual Studio and Visual Studio Code. Learn to set breakpoints, step through code, inspect variables, and use tools like Watch and Call Stack. Understand how to control program flow during debugging for more effective troubleshooting and bug fixing in C# applications.
The Visual Studio and Visual Studio Code IDEs provide debugger toolbars that give quick access to controls that allow stepping through code, inspecting variables, and fixing bugs. Debugging windows show valuable information like variable values, call stacks, and breakpoints. The toolbars make debugging easier by allowing us to control execution flow and visibility into the program state as we walk through the code.
Navigating with the debugger toolbar
Visual Studio Code shows a floating toolbar with buttons to make it easy to access debugging features. Visual Studio 2022 has:
- Two debug-related buttons in its Standard toolbar to start or continue debugging.
- Hot reload changes to the running code.
- A separate “Debug” toolbar for the rest of the tools.
Both are shown and described in the following figure and list, respectively:
Start/Continue/F5: This button is context-sensitive. It will either start a project running or continue running it from its current position until it ends or hits a breakpoint.
Hot Reload: This button will reload compiled code changes without restarting the app.
Break All: This button will break into a running app's next available line of code.
Stop Debugging/Stop/Shift + F5 (red square): This button will stop the debugging session. ...