Predicates and Lists

Posted by George on Stack Overflow See other posts from Stack Overflow or by George
Published on 2010-03-16T14:42:56Z Indexed on 2010/03/16 14:46 UTC
Read the original article Hit count: 221

Filed under:
|
|
|

Hello guys,

I have a generic list.

Some elements of this list belong to a parent element. I retrieved all these elements from a database and i want to recursively build a tree with them.

So, here's what i'm thinking:

Here is my predicate:

public static bool FindChildren(Int32 parentId,CategoryMapping catMapping)
{
    if (catMapping.parentId == parentId)
    {
        return true;
    }
    else
    {
        return false;
    }
}

root = list[0];
root.childrenElements = root.FindAll(FindChildren(root.id,???)

I can't figure out how this would work. How can i do this kind of predicate?

© Stack Overflow or respective owner

Related posts about c#

Related posts about predicate