Collection type for representing a hierarchial structure in .Net 3.5
-
11-07-2019 - |
Question
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?
OTHER TIPS
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
System.Web.UI.IHierarchicalEnumerable
is an interesting pattern.
I'm afraid there is nothing there by default. Make your own.
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.