Click here to Skip to main content
15,885,881 members
Articles / Programming Languages / C#

General trees persisted in relational databases

,
Rate me:
Please Sign up or sign in to vote.
4.46/5 (22 votes)
23 Jun 200311 min read 200.1K   1.9K   84  
Persisting general trees in relational databases with fast path-finding capabilities.
using System;
using System.Collections;

public class TreeNode {
	TreeNode parent;
	object userObject;
	IList children = new ArrayList();
	
    public TreeNode(object userObject) {
		this.userObject = userObject;
    	parent = null;
    }
    
    public void Add(TreeNode child) {
    	children.Add(child);
    	child.Parent = this;
    }
    
    public TreeNode Parent {
    	get {
    		return parent;
    	} set {
    		this.parent = value;
    	}
    }
    
    public int ChildCount {
    	get {
    		return children.Count;
    	}
    }
    
    public IList Children {
    	get {
    		return children;
    	}
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Romania Romania
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Written By
Software Developer (Senior)
Romania Romania
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions