ymihere
ymihere

Reputation: 381

Call a F# Function in VB (or C# or whatever)

It seems I am not able to call a dummy function created in F# from C# and/or VB.Net in Visual Studio 2010 Beta 1.

Most references dug up by Google resolve issues arising in older versions of Visual Studio and CTPs of F#.

It would rock if somebody could post a small howto. Thanks in advance.

Upvotes: 3

Views: 361

Answers (3)

Brian
Brian

Reputation: 118865

F#:

// in Program.fs, last file in project
let Foo() =
    printfn "Hello from F#"

C#:

Program.Foo();

Upvotes: 5

Brian
Brian

Reputation: 118865

F#:

namespace MyFSharpCode

type MyType() =
    static member Foo() =
        printfn "Hello from F#"

C#:

MyFSharpCode.MyType.Foo();     

Upvotes: 3

Mark Seemann
Mark Seemann

Reputation: 233125

You will need to make the F# code publicly available to other callers by encapsulating it in a type.

Upvotes: -1

Related Questions