The purpose of this studio is to talk about your current debugging strategies and how to make the most of the debugger tools discussed in this chapter.
Before we start practicing with debugging tools, go over with the group one error you encountered with any exercise, studio, or book example using Visual Studio. This could be the result of a typo or a logical error.
As you build your code for today’s studio, explore the colorations, icons, and other intellisense features of Visual Studio. Don’t forget to try the debugger if something isn’t working as you planned, or even if it is working as you planned.
To get started: Create a new console application in Visual Studio for the studio. You can refer back to how to create a new C# project.
Write a program that prompts the user for the radius of a circle. Calculate the area of the user’s circle and print the result.
Recall that the area of a circle is
A = pi * r * r where
r is the radius.
Here’s an example of how your program should work:
Enter a radius: 2.5 The area of a circle of radius 2.5 is: 19.625
Some questions to ask yourself:
radiusof that type?
2*pi*r) and diameter of the circle (
To get started, try the following:
circumferenceto the Watch pane to track the value of that property. Does it change?
Program.csand make note of where you expect the program to break its execution.
After you look through the code and try out these tasks, take it one step further by answering these questions.
Once you have gone through the code, open up a piece of code you have been struggling with. In what ways could making use of debugging tools help you figure out what is going on with the code?
Circleclass and leave the user questions and console messages in
Program. Take a look at for a refresher on using another class file.