This chapter talks about the functional programming capabilities of C# and how to use them for a .NET Standard 2.0 library. Let's look at a definition of functional programming:
"Functional programming is a style that treats computation as the evaluation of mathematical functions and avoids changing state and mutable data."
Simply put, it means you will be able to use functions as inputs and outputs for other functions. You can also assign them to variables and store them in collections. Have a look at the following code, which explains what we just talked about:
Func<int, int> addNumbers = n => n + 1; var answer = addNumbers(1); answer // 2 var range = Enumerable.Range(1, 5); var answers = range.Select(addNumbers); answers // 2, 3, 4, 5, 6
Again, when we follow the functional paradigm, we must avoid state mutation. This means that when an object is created, it never changes; variables should never be reassigned. Functional programming has been around for quite a while...