Search⌘ K
AI Features

Debugging During Development and Setting Breakpoint

Explore debugging techniques during C# development by setting breakpoints and using Visual Studio Debugger tools. Learn to identify bugs through step-by-step code inspection, troubleshoot issues with integrated terminal settings, and apply these skills to improve code reliability and correctness.

We will learn how to debug problems at development time. Using a code editor with debugging tools, such as Visual Studio 2022 or Visual Studio Code, would be best. At the time of writing, we cannot use .NET Interactive Notebooks to debug code, but this is expected to be added.

Note: Some people find setting up the OmniSharp debugger for Visual Studio Code tricky. We have included instructions for the most common issues, but if you still have trouble, try reading the information.

Using the Visual Studio Code integrated terminal during debugging

By default, OmniSharp sets the console to use the internal console during debugging, which does not allow interactions like entering text from the ReadLine method. To improve the experience, we can change a setting to use the integrated terminal instead:

Step 1: In any project where we want to set breakpoints and step through code, in the .vscode folder, open the launch.json file.

Step 2: Change the console setting from ... ...