In F# i have the function:
module ModuleName
let X (y: int -> unit) = ()
How can i call this in C#? Ideally it would look like
ModuleName.X(x => x*x);
But this lambda syntax does not convert implicitly to a FSharpFunc.
The easiest approach would be to expose your API using standard .NET delegate types. In this case, that means that your F# definition should look more like:
let X (y:Action<int>) = ()
However, if you want to keep your F# API the same as it currently is, then you could use FuncConvert.ToFSharpFunc
from the C# side:
ModuleName.X(FuncConvert.ToFSharpFunc(x => x*x));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With