Ad

What Is The Best Way To Dump Entire Objects To A Log In C#?

- 1 answer

So for viewing a current object's state at runtime, I really like what the Visual Studio Immediate window gives me. Just doing a simple

? objectname

Will give me a nicely formatted 'dump' of the object.

Is there an easy way to do this in code, so I can do something similar when logging?

Ad

Answer

You could base something on the ObjectDumper code that ships with the Linq samples.
Have also a look at the answer of this related question to get a sample.

Ad
source: stackoverflow.com
Ad