Using expressions as descriptors of members on types
Expressions represent a way of describing intent in a declarative fashion. Rather than with an imperative approach where we tell the computer exactly what to do, we can declaratively describe it and let the code decide the best way to approach it.
As we saw earlier with the filtering of numbers, the imperative approach using foreach does not open for any other execution than what we have put in. While with the LINQ and expression approach, we describe what we want, and the execution is deferred, how it is handled and executed, we don’t know – but the results are the same.
This type of declarative thinking can be a very powerful way to describe what you want for your system and can also make your code more readable and easier for others to reason about. Imperative code requires you to thoroughly read and understand what the code does, while a declarative approach describes the desired outcome and is much easier...