Coffeehouse Post

Single Post Permalink

View Thread: F# Object Expressions for C#
  • stun

    F# Object Expressions http://msdn.microsoft.com/en-us/library/dd233237.aspx

    I even commented about it a year or two ago of how I wanted to be able to create an anonymous object of an Interface. I want it implemented for C# also!  Maybe we can hope for it for C# 6.0.

    type IFirst =
        abstract F : unit -> unit
        abstract G : unit -> unit
    
    
    type ISecond =
        inherit IFirst
        abstract H : unit -> unit
        abstract J : unit -> unit
    
    
    let implementer() = {
        new ISecond with
            member this.H() = ()
            member this.J() = ()
    
        interface IFirst with
            member this.F() = ()
            member this.G() = ()
    }