Introduction to F#
In Chapter 1, Getting Started, we discussed the F# language and its functional programming features, basic keywords, operators, and variable declarations. We also looked at the difference between F# and C#, functions, and the basic input-output syntax. In this section, we will discuss F# in more detail.
Basics of classes
Classes are types of object which can contain functions, properties, and events. An F# class must have a parameter and a function attached like a member. Both properties and functions can use the member
keyword. The following is the class definition syntax:
type [access-modifier] type-name [type-params] [access-modifier] (parameter-list) [ as identifier ] = [ class ] [ inherit base-type-name(base-constructor-args) ] [ let-bindings ] [ do-bindings ] member-list [ end ] // Mutually recursive class definitions: type [access-modifier] type-name1 ... and [access-modifier] type-name2 ...
Let’s discuss the preceding syntax for class declaration:
type
: In the F...