Chapter 18. C#

WHAT'S IN THIS CHAPTER?

  • Calling C# libraries from F#

  • Exploring the complexities of C# libraries

  • Calling F# libraries from C#

  • Structuring F# libraries for C# consumption

  • Avoiding common pitfalls

While F# is definitely useful on its own, if it were unable to leverage programs written in other languages such as C#, it would be far less practical for general use than it could be. And C# programs greatly benefit from using new F# programs. This chapter explains how these two languages can interoperate together and provides some tips to make that interoperation easier.

OVERVIEW

One of the most significant reasons why F# is a compelling functional language is that it is best positioned for broad usage among software developers on the .NET platform. It isn't the only functional language in that it not only can leverage the .NET framework but there are also many others — including implementations of Clojure and Scheme. What sets F# apart is not only "inclusion in the box" as part of Visual Studio, but also the downstream implications of that, meaning it will be available to a broader pool of developers, which leads to broader skill availability, which helps build a talent base that makes organizations more likely to consider using the language.

Of course, none of this would be possible if these more risk-averse organizations could leverage existing investments in C# in their F# programs. Although it would be nice to live in an "ideal programmer world" where one picks and chooses the ...

Get Professional F# 2.0 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.