Chapter 2. Using F# for Object-Oriented Programming

Object-oriented programming (OOP) has been a great success. Many modern business systems are designed and implemented by applying OOP concepts. I will not discuss the benefit of using OOP because, as a C# developer, you probably already have hundreds of such benefits in mind.

F# is a multiparadigm language that supports OOP. Practically everything you can do with C# can be done with F#, and usually with less code. I will follow the approach from the first chapter, converting C# code to F#. Example 2-1 shows a C# Point2D class, which represents a point on a two-dimensional (2D) surface. It shows properties, static and nonstatic fields, an attribute, and member methods. The conversion task will ...

Get F# for C# Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.