Pages

Friday, November 5, 2010

F# interop with C#

In F# file:

namespace AA

    [ < system.runtime.compilerservices.extension > ]
    module BB =
        [< system.runtime.compilerservices.extension > 
        let F(i:System.Int32, first:char, last:char) = {first .. last}

        let F2(a,b) = 12

In C#, you can call:


            int a = 3;
            var list = a.F('a', 'z');
            var b = BB.F2(a, 0.5);

No comments: