Skip to Content
Functional Programming with C#
book

Functional Programming with C#

by Simon J. Painter
September 2023
Intermediate to advanced
325 pages
7h 45m
English
O'Reilly Media, Inc.
Content preview from Functional Programming with C#

Chapter 3. Functional Coding in C# 7 and Beyond

I’m not sure when exactly the decision was made to make C# a hybrid object-oriented/functional language. The first foundation work was laid in C# 3. That was when features like lambda expressions and anonymous types were introduced, which later went on to form parts of LINQ in .NET 3.5.

After that, though, there wasn’t much new in terms of functional features for quite some time. In fact, it wasn’t really until the release of C# 7 in 2017 that FP seemed to become relevant again to the C# team. From C# 7 onward, every version of C# has contained something new and exciting to do more functional-style coding, a trend that doesn’t currently show any signs of stopping!

Chapter 2 introduced functional features that could be implemented in just about any C# codebase likely to still be in use out in the wild. In this chapter, we’re going to throw away that assumption and look at all the features you can use if your codebase is allowed to use any of the latest features—or at least those released since C# 7.

Tuples

Tuples were introduced in C# 7. NuGet packages do exist to allow some of the older versions of C# to use them too. They’re basically a way to throw together a quick-and-dirty collection of properties, without having to create and maintain a class.

If we have a few properties we want to hold onto for a minute in one place and then dispose of immediately, tuples are great for that.

If we have multiple objects we want to pass between ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Functional Programming in C#

Functional Programming in C#

Enrico Buonanno

Publisher Resources

ISBN: 9781492097068Errata Page