开发者

How to implement Dump as the one provided by LinqPad? [duplicate]

This question already has answers here: 开发者_运维百科 How do I use the LINQPad Dump() extension method in Visual Studio? [closed] (4 answers) Closed 8 years ago.

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, DataTables, Images, 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜