views:

461

answers:

4

I remember seeing a while ago that there is some method in maybe the Reflection namespace that would recursively run ToString() on all of an object's properties and format it nicely for display.

Yes, I know everything I could want will be accessible through the debugger, but I'm wondering if anyone knows that command?

A: 

I could certainly see the use in such a thing, but in .Net won't you mostly just get a list of type names (String, Array, etc)? Most of the built-ins don't have "useful" ToString() overloads pre-written, do they?

cori
+2  A: 

Example code to dump an object and its properties can be found here:

http://www.developer.com/net/csharp/article.php/3713886

Martin
+2  A: 

I think what you're looking for is/was called ObjectDumper. It uses reflection to iterate through and output all of the different properties for an object. I first heard about it while learning LINQ, and most of the examples in the Linq in Action book use it.

It appears that Microsoft didn't include it in the final version of Linq though, but the code is still out in the wild. I did a quick google search for it and here's a link to it:

ObjectDumper Source Code

A: 

Here is a link with code dumper and a demo project that shows you how to use it. Download it here.

sontek