On Mon, 05 May 2008 09:26:49 -0700, csharpula csharp <cs*******@yahoo.com>
wrote:
I would like to know what is the best way to store a tree structure in
c#?
That depends on the nature of the tree. However, it's simple enough to
write your own class that maintains a tree in whatever manner is
appropriate for your data. Common tree implementations would include
references to children either via a fixed number of instance fields (e.g.
binary tree) or an instance field that holds a reference to a collection
of child nodes (e.g. a List<Tinstance containing all the children for
that node).
Are there any good implementation examples for seing how to do it?
A number of Framework classes use tree-like collections. You certainly
could examine them to learn more about different .NET implementations that
exist. For example, the Control class (Control.Controls), the TreeView
class (TreeView.Nodes, and TreeNode.Nodes), and the generic SortedList<T>
class, to name a few.
Pete