News for hackers. Stuff that matters.
Re:Ask HN: How do you get better at using LINQ? by btschaegg on Wednesday February 01, 2017 @11:36AM (#13542171)
I've never really struggled with the concept, so I can't point you to resources that "clicked" for me. However, since LINQ basically just implements basic functional collection handling mechanisms, a look at how other programming enviroments deal with the idea might be helpful. To name a few things based on the same principles:

- Lisp's map, filter, reduce functions and derivates of them

-jQuery

- C++'s std algorithm

- Python Generators (in compination with Lisp-style functions)

-SQL's SELECT statements

Maybe, seeing them used could give you better ideas on how to use LINQ.

In terms of the necessary mindset, I would try to shift the focus from "What can I do with LINQ" to "what can't I do".

LINQ is immensely powerful and generally seems to decouple collection handling code, so I'd generally write everything I can with LINQ statements and just factor the steps out that are not feasible or get too complicated.

If you struggle with starting such a statement, try to describe, what you want to do - in steps performed on your collection(s) of input data:

"First, remove duplicates" -> Distinct()

"Then, only consider property X for each object in the collection" -> Select()

...and so on.

There are no comments on this comment yet.