Debugging during development
In this section, you will learn how to debug problems at development time.
Creating code with a deliberate bug
Let's explore debugging by creating a console app with a deliberate bug that we will then use the tools to track down and fix.
- In
Chapter04
, create a folder namedDebugging
, add it to the workspace, and create a console application in the folder. - Navigate to View | Command Palette, enter and select OmniSharp: Select Project, and then select the Debugging project.
- In the
Debugging
folder, open and modifyProgram.cs
to define a function with a deliberate bug and call it in theMain
method, as shown in the following code:using static System.Console; namespace Debugging { class Program { static double Add(double a, double b) { return a * b; // deliberate bug! } static void Main(string[] args) { double a = 4.5; // or use var double b = 2.5; double answer = Add(a, b); WriteLine...