Q&A
Ask and answer questions to make information more available to wider audiences.
Maximiliano Alderman @aldermanmaximiliano   23, May 2023 12:00 AM
inheritance
What is an inheritance in F#?
answers 1
 
Answer 1
Noah Antills @noahantills   31, May 2023 12:54 PM
In F#, inheritance is a process in which child class acquires all the properties and behaviors of its parent class automatically. It is used to reuse the code.

Example
type Employee(name:string) =  
 class  
  member this.ShowName() = printf"Name = %s\n" name  
 end  
type Manager(name,salary:int) =  
 class  
  inherit Employee(name)  
  member this.ShowSalary() = printf"Salary = $%d" salary  
 end  
let manager = new Manager("Rajkumar",10000)  
manager.ShowName()  
manager.ShowSalary()