O'Reilly logo

Learning C# 2005, 2nd Edition by Brian MacDonald, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9: Basic Debugging

Quiz

Solution to Question 9–1.

Go to the line where you want execution to stop, and click in the margin. A red dot will appear on the line.

Solution to Question 9–2.

Pressing F10 steps over a method; F11 steps into the method.

Solution to Question 9–3.

Right-click on the line and choose breakpoints and then disable breakpoint, or right-click on the breakpoint and choose disable.

Solution to Question 9–4.

The Locals window shows all the variables that are in scope. The Autos window shows variables used in the current and previous statement.

Solution to Question 9–5.

Either right-click on the variable and choose “Add to Watch window” or just click and drag the variable directly onto the Watch window.

Solution to Question 9–6.

Right-click on the variable and choose “QuickWatch,” or select Debug → QuickWatch.

Solution to Question 9–7.

The call stack shows which method called the current method, and which method called that method, etc. This allows you to determine the exact path your code followed to bring you to the current method.

Exercises

Solution to Exercise 9-1.

You’ll use the following program for this exercise. Either type it into Visual Studio, or copy it from this book’s web site. Note that this is spaghetti code—you’d never write method calls like this, but that’s why this is the debugging chapter.

using System; namespace Debugging { class Tester { public void Run( ) { int myInt = 42; float myFloat = 9.685f; System.Console.WriteLine("Before staring: \n value of myInt: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required