- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
All of them are useful and readable for me. Which of them is the best, depends on reason and who is the consumer of this snippet.
I prefer to split collecting the objects and do some action on them. Because often I need more complex action then one line of code (error handling, logging, comments, etc.) (=> Snippets 3, 4)
I don't know how familiar with LINQ are members of this forum. If they want to modify or reuse the snippet, it can be little bit confusing for them. (=> Snippet 4)
Snippet 1 is very compressed form and it is suitable for some internal functions in addins or other "closed" code.
Snippet 2 is nice example how to use LINQ for simple task, but as I mentioned above, it can be hard to modify this code for many of non-advanced users.