In this video, learn how you can use inspector windows in conjunction with breakpoints to debug your programs, and learn how to inspect the current value of a given variable during a program's execution with the watch window.
- [Instructor] Let's take a look at the different ways … we can inspect our variables with break points. … Here we have a program that should find the max … of two numbers. … Of course, it's not working perfectly … so we'll need to inspect the program as it's executing, … to find the error and come up with a solution. … Let's go ahead and run this program … and see what we get as output. … Here we get three. … The input, to our find max function, is three and eight. … This means we're returning the minimum … instead of the maximum. … Let's put some break points in here … and try to find the error. … On line 10, we can add a break point … right after we calculate what the max is. … Let's go ahead and run the program again, … and we'll see it stop at that point in execution, … and we should be able to see the values … of these local variables. … And so we see three, eight, but our max is three. … Let's take a closer look at this line nine here. … And we see if a is greater than b, … then we want to return b. …
Released
4/23/2019- Debugging defined
- Working with breakpoints
- Inspecting values of variables
- Defensive programming
- Common C# errors
- Debugging challenges
Share this video
Embed this video
Video: Inspecting values of variables