Friday, August 15, 2008

"Cool C# sample that's probably on your hard drive yet you may have never seen" of the day - ObjectDumper.CS

Eric White's Blog - Object Dumper: An Invaluable Tool for Writing Code in the Functional Programming Style

"When developing C# programs in the functional programming style, you often need to dump out a collection to the console. Object dumper is a great tool to use for this. It is a sample that far too few developers know about.

...

To use it, just add ObjectDumper.cs to your project.

For the simplest use, you can simply pass any object to ObjectDumper:

var z = new

    {

        A = "1",

        B = "2"

    };

 

ObjectDumper.Write(z);

This produces the following output:

A=1 B=2

..."

Nice. Not quite as cool as the LINQPad .Dump(), but still pretty useful when you need to [juvenal humor deleted]. And at least this one you have the source for... :)

This can be found in (at least on my machine) "C:\Program Files\Microsoft Visual Studio 9.0\Samples\1033\CSharpSamples.zip" in the "\LinqSamples\ObjectDumper\" folder.

No comments: