From the course: Debugging in C#

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Inspecting values of variables

Inspecting values of variables

From the course: Debugging in C#

Start my 1-month free trial

Inspecting values of variables

- [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. So that means if a is…

Contents