views:

233

answers:

5

I been experimenting with the different methods for representing a hierarchical structures in memory that would allow for simple and efficient transversal both up and down to discover ancestor and descendant relationships. Does anyone have any suggestions or examples of the options that I have? Is there a collection type in .Net 3.5 that would help here?

+1  A: 

So you want a Tree? FGI

David Kemp
Thanks David, that looks very promising.
Stephen franklin
A: 

How about making your own node that looks something like:

  class Node<T> {
    public T Item;
    public LinkedList<T> Children;
  }

Then apply Node recursively, as needed

GregUzelac
Children should be a LinkedList<Node<T>>, not a LinkedList<T>.
Robert Rossney
A: 

System.Web.UI.IHierarchicalEnumerable is an interesting pattern.

Bryan Watts
A: 

I'm afraid there is nothing there by default. Make your own.

Vilx-
A: 

I use LINQ to traverse hierarchical structures that I loaded from XML web services but I bet LINQ would generalize nicely to walk around your tree collection.

-Mike

PS. I mention this because LINQ is just plain fun too.

Mike Bonnell