THE .NET FRAMEWORK

Since its first versions, the .NET Framework and its languages have had certain influences from functional programming. From the outside it’s hard to judge whether somebody from the Framework team came up with the idea of creating a System.Delegate type, or whether that was set in motion by the language teams. However, this happened before the first version of the .NET Framework became publicly available, and it is a great improvement over the loosely typed function pointers available in many other, usually older, object oriented languages. In the same way, some patterns were implemented in a functional fashion from the get-go.

The IEnumerable and IEnumerator interfaces provide one example of a framework feature that allows for all the lazy evaluation goodness of sequences in functional languages, although the first version of C# only implemented the reading of such sequences with the foreach keyword. Programmers had to wait for C# 2.0 if they wanted an easy way to construct such sequences themselves, but when it came in the shape of iterators, it was another feature reminiscent of the approaches found in functional languages.

.NET version 2.0 was a larger release in terms of new framework features in the realm of functional approaches. Iterators, as mentioned, are a language feature. Generics, which are not strictly a framework feature but are of the type system, were introduced. Of course Framework support is required for generics — in the form of changes to ...

Get Functional Programming in C#: Classic Programming Techniques for Modern Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.