Functional Programming in C# (.NET)
300 pages
English
PDF
4.5

Functional Programming in C# (.NET)

Functional Programming in C# (.NET)

Author:

Year:

Summary:

The book "Functional Programming in C# (.NET)" is a practical guide that will help C# developers master the functional paradigm in the context of the modern .NET platform. The author, Alexey Ilyin, consistently guides the reader from basic principles (pure functions, data immutability) to complex concepts (monads, functors, lazy evaluation), showing how to apply them in real projects.



What is this book about?

  • Fundamentals of the functional approach: why immutability reduces the number of errors, how pure functions and side effects work.
  • Deep dive into LINQ: from query syntax to creating custom operators and providers.
  • Advanced techniques: function composition, currying, partial application, recursion, and tail recursion optimization.
  • Working with monads: Option, Either, Try, State — how to avoid null references and handle errors without exceptions.
  • Functional design patterns: dependency injection without classes, functional facades, interpreters.
  • Integration with imperative code: how to gradually introduce functional practices into existing C# projects.
  • Performance: when functional code is faster than imperative code, and when it is not.


Who is this book for?

  • C# developers of any level who want to expand their toolkit.
  • Programmers transitioning from Java or Python to .NET who are familiar with the functional style.
  • Architects who want to design more reliable and testable systems.


What will you learn?

  • How to write code without side effects and with predictable behavior.
  • How to effectively use LINQ not only for collections, but also for streams, asynchronous operations, and error handling.
  • How to build chains of data transformations without temporary variables.
  • How to implement your own monads and work with contexts (Maybe, Either, Writer).
  • How to test functional code: unit tests for pure functions and property-based testing.
  • How to refactor legacy code by replacing imperative loops with declarative constructs.


All examples are written in C# 12 for .NET 8 and come with explanations. The book is suitable both for self-study and for use as a reference. By mastering the material, you will be able to write more concise, reliable, and easily maintainable code using the best practices of functional programming in the .NET ecosystem.

Recommendations