F# Riddle: how to call an overload of a method?

c#, call, f#, interop, methods

Solution

Here's an answer to the F# part:

MyClass.Overload1(1,2)
MyClass.Overload1<_,_>(unbox (box (1,2)) : System.Tuple<int,int>)
MyClass.Overload1 1

Problem

First part: call F# from F# Let's say we have the following type defined in F#: ``` type MyClass = static member Overload1 (x, y) = "Pim" static member Overload1 (x : System.Tuple<_, _>) = "Pam" static member Overload1 x = "Pum" ``` You are now in another module (in another file). How can you call each of the three methods shown above? Second part: call C# from F# Now, you define a class in C#: ``` public class MyClass { public static string Overload1<a, b>(a x, b y) { return "Pim"; } public static string Overload1<a, b>(Tuple<a, b> x) { return "Pam"; } public static string Overload1<a>(a x) { return "Pum"; } } ``` From a F# code, how can you call each of the three methods now defined in C#?

Original source