Google News
logo
F# - Interview Questions
What is method overriding in F#?
Method overriding is a feature of Object-oriented programming approach. It helps to achieve polymorphism. We can achieve method overriding using inheritance.
 
Example :
type Employee() =  
 class  
  abstract ShowName : unit -> unit  
  default this.ShowName() = printfn"This is base class method"  
 end   
type Manager() =  
 class  
  inherit Employee()  
  override this.ShowName() = printf "This is derived class method"  
 end  
  
let employee = new Employee()  
let manager = new Manager()  
employee.ShowName()  
manager.ShowName()
Advertisement