views:

374

answers:

4

I like Microsoft's Windows Forms tree-view object model. It has the tree, nodes, children collection, parent, prev, next (sibling), etc. and search function. However I'm looking for the same object model with no UI - simply tree object model.

Does C# have this kind of model or do I have to implement it myself?

+1  A: 

C# is a programming language. It does not have object models.

You may be asking whether the .NET Framework has a built-in "tree" class. It does not. You can build your own using the generic collection classes like LinkedList<T> and List<T>.

John Saunders
lol pwned......
Janie
A: 

You could always use XML and the XML namespaces. It's got all the things you requested. Start with and XMLDocument and keep added XMLNodes and adding XMLNodes to the XMLNodes for children. Then you can use xpath queries to retrieve nodes.

gjutras
A: 

An XmlDocument object is the closest match I can think of to your requirements. It supports parent, child, previous, next, sibling, etc. You can also use XPath to query the tree and return a specific node or sets of nodes. Also, because it's Xml you can easily import and export the data to/from a text file.

tbreffni
A: 

I suggest you read about binary trees on MSDN. It will teach you how to model tree data structures in code.

Good luck.

Matthew