Dump an arbitrary object To Html String
- by Michael Freidgeim
For debugging purposes me and my collegue wanted to dump details of the arbitrary object, and created function that uses LINQPad Dump functionality (thanks to http://stackoverflow.com/a/6035014/52277 and original http://linqpad.uservoice.com/forums/18302-linqpad-feature-suggestions/suggestions/447166-make-dump-extension-method-available-in-visual-s discussion) public static string DumpToHtmlString<T>(this T objectToSerialize) { string strHTML = ""; try { var writer = LINQPad.Util.CreateXhtmlWriter(true); writer.Write(objectToSerialize); strHTML = writer.ToString(); } catch (Exception exc) { Debug.Assert(false, "Investigate why ?" + exc); } return strHTML; }You will need to add the linqpad executable as a reference in your project.TO DO similar in plain text ,look at https://github.com/ServiceStack/ServiceStack.Text StringExtensions , e.g. JsonSerializer/CsvSerializer or http://objectdumper.codeplex.com/