Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Thomas Dolberg 74 posts 95 karma points
    May 08, 2011 @ 00:20
    Thomas Dolberg
    0

    Getting childnodeids

    Is there a way to get an array of all childnodeids without having to iterate over all nodes in the Children-collection?

     

    thanks

    Thomas

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    May 08, 2011 @ 11:40
    Bo Damgaard Mortensen
    1

    Hi Thomas,

    I'm not sure, but I would think you have to loop through the children collection of a parent node in order to get their id's. How about a little linq, maybe? This is not tested, just written straight in the editor :-)

    var test = (from childnode in parent.Children
                select childnode.Id).ToList();

    / Bo

  • Thomas Dolberg 74 posts 95 karma points
    May 08, 2011 @ 13:35
    Thomas Dolberg
    0

    Hi Bo

     

    thanks - it worked :-)

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    May 08, 2011 @ 13:58
    Bo Damgaard Mortensen
    0

    Glad it worked!

    Still, i'm not too sure if using the linq query is actually faster than using a foreach loop. There's a lot of tests out there that shows that linq queries performs worse than a simple foreach. You might check up on that and save some overhead where it can be saved :-)

    / Bo

Please Sign in or register to post replies

Write your reply to:

Draft