Ask Learn Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
During your journey as a developer, there's always that moment when you end up asking yourself:
Why isn't my code working?
Asking this question is a normal part of any developer's day. The trick is to get comfortable with finding and fixing your bugs with a minimum of time and frustration. When there's a bug in a program, everyone usually has their own way of dealing with this problem.
You've probably already tried one or more of these debugging approaches yourself:
Console.WriteLine("here")
messages in your code.You might have various degrees of success with these methods. The one approach that's commonly regarded as being more often successful is using a debugger. But what's a debugger, exactly?
A debugger is a software tool you can use to observe and control the execution flow of your program with an analytical approach. Its design goal is to help find the root cause of a bug and help you resolve it. It works by either hosting your program in its own execution process or running as a separate process that's attached to your running program, like .NET.
Debuggers come in different flavors. Some work directly from the command line, while others come with a graphical user interface. In this module, we'll use Visual Studio Code's integrated graphical debugger.
If you're not running your code through a debugger, that means you're probably guessing what's happening in your program. The primary benefit of using a debugger is that you can watch your program running. You can follow your program execution one line of code at a time. In this way, you avoid the chance of guessing wrong.
Every debugger has its own set of features. The two most important ones that come with almost all of them are:
Mastering debugger usage is an important skill for a developer that's often overlooked. It makes you more efficient at hunting bugs in your code and can help you quickly understand how a program works.
Let's discover that in the next unit.
Having an issue? We can help!
Please sign in to use this experience.
Sign in