Reputation: 6057
I wrote a small F# library while messing around that contains a few math functions like the following:
namespace MyLib
type Math() =
member this.add(a,b) =
a+b
Now, I am trying to call it from C# like:
using System;
using MyLib;
class Test {
static void main(string[] args) {
Double sum = MyLib.add(1.2, 3.5)
Console.WriteLine(sum.ToString());
}
}
This code gives me an error, When I look at the function's signature, I see that it accepts two integers.
The reason I am using Double
s is because in another function, I am using F# exponentiation. How can I tell an F# function that it should accept Double
s as apposed to int
s
Upvotes: 0
Views: 99
Reputation: 80744
You can just add a type annotation explicitly:
type Math() =
member this.add(a:float,b:float) =
a+b
(note that System.Double
is called float
in F#)
Upvotes: 2