Section 2.6. Examine Objects While Debugging Them


2.6. Examine Objects While Debugging Them

In Visual Studio 2005 you can look inside complex objects, including user-defined classes and collections, right from within the editor. You do so by hovering your mouse cursor over the object while in debug mode. This is the same as in previous versions of Visual Studio, but the amount of information provided is much greater than before.


Note: Now you can peer inside complex objects. It's MRI for programmers.

2.6.1. How do I do that?

To see an example of how to look at the state of complex objects, place a breakpoint on the last line of the SimplifyCoding program shown in Example 2-1. Run the debugger to the breakpoint and place your cursor over the variable d, which represents an instance of Dog. Notice that the text that would be rendered by calling ToString on the Dog object is shown, just as in previous versions. Now, however, a plus sign (+) appears next to the variable. Hover your mouse cursor over the plus sign; the plus sign turns to a minus sign, and you'll see the internals of the instance, as shown in Figure 2-19.

Figure 2-19. Looking inside objects


2.6.2. What about . . .

...seeing other types of data such as XML or datasets?

The debugger comes with built-in visualizers for text, HTML, and XML. You are also free to create your own. The next lab examines how to use the XML Visualizer.

2.6.3. Where can I learn more?

A number of good books on using debuggers are available, including the seminal work Code Complete by Steve McConnell (Microsoft Press).



Visual C# 2005(c) A Developer's Notebook
Visual C# 2005: A Developers Notebook
ISBN: 059600799X
EAN: 2147483647
Year: 2006
Pages: 95
Authors: Jesse Liberty

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net