In F#, we can override System.Object
methods when creating new object instances with object expressions. This can be very useful when one wants to quickly print with the ToString()
method:
let obj = { new System.Object() with member x.ToString() = "F#" }
printfn "%A" obj
However, when should I need to create new objects in C#, beside lock statements?
var obj = new object();
Console.WriteLine(obj);