Google News
logo
F# - Interview Questions
What is a self in F#?
In F#, a self is used to refer the current object of class type. Self is the same as this keyword in C# and Java. You can name the self-identifier however you want. You are not restricted to names such as this or self as in .Net languages.
 
Example :
type Employee(id,name) as this =  
    let id = id  
    let name = name  
    do this.Display()           // This is how we can use self(this) object  
    member this.Display() =  
        printf "%d %s" id name  
let e =new Employee(100, "Ramana")
Advertisement