Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Eric Lippert's challenge - cleanererer

By: a guest on Sep 10th, 2010  |  syntax: C#  |  size: 0.51 KB  |  hits: 43  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. sealed class Dumper
  2. {
  3.     static public string Dump(Node root)
  4.     {
  5.         return Dump( root, "" );
  6.     }
  7.     static private string Dump(Node node, string indent)
  8.     {
  9.         return node.Text + "\n" + node.Children.Take(node.Children.Count - 1)
  10.             .Aggregate(string.Empty,
  11.                 (results, child) => results + indent + "├─" + Dump(child, indent + "│ ") ) +
  12.             ( node.Children.Count == 0 ? "" : indent + "└─" + Dump(node.Children.Last(), indent + "  " ) );
  13.     }
  14. }