- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Personally, I don’t think snippet 1 is good in any situation. It is too compressed to read. My personal guild line is that a line of code should never be longer than 100 characters and a function should never be longer than what fits on the screen. (However, I find myself often in situations where functions are too long.) That is also why I think snippet 2 is better than 1.
But Using the foreach function from LINQ is not something I do often. Most of the time I have multiple lines of code in a foreach loop and I don’t think you should use multiple lines of code in a LINQ function.
So I think snippet 3 is the best if I expect that my code will only be read by someone with some coding experience. But I agree with @Michael.Navara that on this forum we often need to explain a little bit more. And maybe then snippet 4 is then the best. But then again I agree with wit @basautomationservices for me it's just too much unnecessary typing. And I don’t think that LINQ code is that hard to read.
Anyway, I guess we are all more on less on the same page. Thank you for your comments.
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com