seraching a Btree (.net Generics), how?



hi 2.0

I have a custom class:

public class Comment
private Guid _id;
private Guid _userid;
private Guid _article;
private Guid _parent;
private List<Comment> _replies;

public comment() {}

okay, my DAL return a list of all comments associated with an article. Some
of those comments might be replies to other comments etc. Now in my BLL (the
class above is within BLL) I want to fix this so that replies to another
comment is not added to the root list but to the comment they are replies

My problem is how do I search my btree to locate where to put the comment,
maybe .NET Generics have some built in feature for this?

I started with this code:
Comment comment = GetCommentFromCommentDetails(record); //Get comment from
if (comment._parent == Guid.Empty) //if no parent, then add to root list
//Here I have to search the btree, not sure how?

any suggestions? any tips about how to display these comments in a data
presentation control is welcome too.



bruce barker

pretty standard recursive search. add this method to the class:

public Comment FindCommentByID(Guid id)
if (this._id == id)
return this;
foreach (var comment in _replies)
var childComment = comment.FindCommentByID(id);
if (childComment != null)
return childComment;
return null;

-- bruce (

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question