In “C:\Program Files (x86)\Microsoft Visual Studio 10.0\Samples\1033”, you will find a zip file called “CSharpSamples.zip”.
Within it you will find a file called ObjectDumper.cs (CSharpSamples\LinqSamples\ObjectDumper). This is a nifty little utility class that you can use to dump the data within an object. (It will walk the object graph to a specified depth which you can then output to console or a textWriter).
To call it you can use the following code:
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
Test test = new Test();
ObjectDumper.Write(test, 1, sw);
Here is the code from that file:
// Copyright © Microsoft Corporation. All Rights Reserved.
// See the ReadMe.html for additional information
public static void Write(object element)
public static void Write(object element, int depth)
public static void Write(object element, int depth, TextWriter log)
private ObjectDumper(int depth)
private void Write(string s)
private void WriteIndent()
private void WriteLine()
private void WriteTab()
private void WriteObject(string prefix, object element)
private void WriteValue(object o)