Click here to Skip to main content
Click here to Skip to main content

Select Recursive Extension method

By , 7 Sep 2010
 
Magnus, I really like the idea! I believe your original idea (posted @ http://www.codeproject.com/KB/linq/LinqToTree.aspx) is even better for the general case - probably better than the solution in the article - it does feel more generic while still being very easy to use.
 
I'm sure you may have already implemented something like this, but if you precede SelectRecursive() with the following, you can begin the operation with a single item.
 
public static IEnumerable<T> YieldSame<T>(this T item)
{
    yield return item;
}
 
// Example
Window w = new Window();
w.YieldSame().SelectRecursive(w => w.OwnedWindows);
 

Again, excellent idea!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

John Adams
United States United States
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralReason for my vote of 5 good ideamembershenron30 May '11 - 0:07 
Reason for my vote of 5
good idea
GeneralThanks John!memberPartenon21 Oct '10 - 5:40 
Thanks John!

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 7 Sep 2010
Article Copyright 2010 by John Adams
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid