Javatpoint Logo
Javatpoint Logo

F# Object and Class

F# is a functional programming language. It also supports object oriented programming approach and allows us to create class and object.

F# Object

Object is a real world entity. It can be anything like ? cell phone, car, football etc.

Object is an instance of class. We can access all the members of class by using object of this class.

Let's see an example of how to create object in F#.

In the above example, objectName is the name of object which refers to class. New is a keyword which is used to allocate memory for object. ClassName is a name of class of which we are creating object.

F# Class

Class is a template or blue print of an object. It is used to encapsulate data members and member methods. It can contain fields, methods, constructors, static methods etc.

F# Class Example

This F# class example has two fields and one method only. We have displayed field values in this method by using object.


12 FSharp

F# Initialize and Display Data through Method


25 RajKumar
26 John
27 Mariam

F# Class Example: Store and Display Employee information


25 RajKumar 25000.00
26 John 26000.00
27 Mariam 27000.00

F# Calling Instance Variable in another Class Example


102 Rajkumar
Next TopicF# Constructor

Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA