Given (new [] {"a", "b"}).Dump()
, LinqPad provides some very useful print results.
It seems that this extension method is a short hand for Console.WriteLine
.
Question> how to implement this dump for myself?
This thread might be of use to you. Is there a library that provides a formatted Dump( ) function like LinqPad?
With a lot of hard work.
Dump
is not a shortcut for Console.WriteLine
; it's an extremely complicated recursive method which turns arbitrary object graphs into HTML, with special support for collections, DataTable
s, Image
s, and a couple of other types.
It also has special output code to format collections of complex objects into tables, and to prevent recursive expansion.
You can grab the Object Dumper
class that is included in the Visual C# 2008 Samples. It won't be in the pretty HTML format used by LINQPad and the other types of output it supports, but the purpose is similar.
精彩评论