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 propertie
Example code to dump an object and its properties can be found here:
http://www.developer.com/net/csharp/article.php/3713886
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
Here is a link with code dumper and a demo project that shows you how to use it. Download it here.
You can write it by yourself. For example, serialize it into json using Newtonsoft's JSON.net library and write that json to console. Here is an example:
using Newtonsoft.Json;
static class Pretty
{
public static void Print<T> (T x)
{
string json = JsonConvert.SerializeObject(x, Formatting.Indented);
Console.WriteLine(json);
}
}
Usage:
Pretty.Print(whatever);
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?