Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 13th, 2010  |  syntax: C#  |  size: 0.66 KB  |  views: 63  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.     static class Dumper
  2.     {
  3.         static public string Dump(Node root)
  4.         {
  5.             return Dump(root, "");
  6.         }
  7.  
  8.         static private string Dump(Node root, string indent)
  9.         {
  10.             string result = root.Text;
  11.             for (int i = 0; i < root.Children.Count; i++)
  12.             {
  13.                 bool isLastNode = (i == root.Children.Count - 1);
  14.  
  15.                 result += "\n";
  16.                 result += indent;
  17.                 result += isLastNode ? "└─" : "├─";
  18.                 result += Dump(root.Children[i], indent + (isLastNode ? "  " : "│ "));
  19.             }
  20.             return result;
  21.         }
  22.     }
clone this paste RAW Paste Data