Click here to Skip to main content
12,355,066 members (50,332 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

3.3K views
Posted

Select Recursive Extension method

, 7 Sep 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
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...
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)

Share

About the Author

John Adams
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralReason for my vote of 5 good idea Pin
shenron30-May-11 0:07
membershenron30-May-11 0:07 
GeneralThanks John! Pin
Partenon21-Oct-10 5:40
memberPartenon21-Oct-10 5:40 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

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