All F# interfaces are implemented explicitly, which means you must upcast to the interface type to call the method:

member x.test : int = (x :> I).bah // ok

This is like in C# if you implement the interface with "I.bah" rather than just "bah".

1
2
3
4
5
6
7
8
9
10
    interface I
    {
        int bah();
    }
    class X : I
    {
        int I.bah() { return 42; }
        //public int test() { return this.bah(); } // error
        public int test() { return ((I)this).bah(); } // ok
    }
By on 8/10/2009 3:57 PM ()

Many thanks!

By on 8/12/2009 5:40 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper