2

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?

Andrei Sfat
  • 8,440
  • 5
  • 49
  • 69
q0987
  • 34,938
  • 69
  • 242
  • 387

3 Answers3

4

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

Community
  • 1
  • 1
jradxl
  • 535
  • 1
  • 4
  • 20
  • I have tried to add LinqPad.exe to my refernece, but I got the following warning. Warning 1 The referenced assembly "LINQPad" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project. ConsoleApplication2 – q0987 Jun 07 '11 at 15:31
  • you need to target the full v4 framework - not the cut-down client profile. Check your project properties. – kjn Jun 17 '11 at 08:10
  • Or download the .NET 3.5 version of LinqPad – TheRealTy Jun 23 '11 at 00:07
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.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
1

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.

Ahmad Mageed
  • 94,561
  • 19
  • 163
  • 174