Sequential numbering from recursive function? e.g. 2, 2.1, 2.1.1, 2.2, 2.2.1

Posted by Pete on Stack Overflow See other posts from Stack Overflow or by Pete
Published on 2010-04-19T14:07:40Z Indexed on 2010/04/19 14:13 UTC
Read the original article Hit count: 279

Filed under:
|

I have a recursive function reading a "table of contents" of documents from a database. I would like to print numbering with the document that reflects where the item is in the tree, e.g.

  1. First item, 1.1 Child of first item, 1.1.1 Child of child of first item, 1.2 Child of first item,
  2. Second item, 2.1 Child of second item,

etc.

Rather stumped about this at the moment - help please?

© Stack Overflow or respective owner

Related posts about recursion

Related posts about c#