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

自闭症网瘾萝莉.ら 提交于 2019-12-24 04:42:05

问题


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?


回答1:


This thread might be of use to you. Is there a library that provides a formatted Dump( ) function like LinqPad?




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/6207386/how-to-implement-dump-as-the-one-provided-by-linqpad

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!