As I said in my comments, C # does not allow you to define new operators, and ** not an operator in C #. ^ is an operator, but it is a logical XOR operator, not an exponential operator. This gave me a hint that F # might translate your C # statement into native F # ( ^^^ for logical XOR).
So, I created a couple of test projects and used your definition of ^ , here is what I found in F #:
open CSLib // CSLib is the C
You can define new global operators in F #, however, if you want it to be a shared library, which might be unacceptable.
You can define the Exponentiation operator to use in F # by specifying the public static Pow method in type Integer in your C # library:
public static Integer Pow(Integer left, Integer right) { if (Integer.IsNaN(left) || Integer.IsNaN(right)) return NaN; return left.RaiseToPower(right); }
Then you can use it directly in F # as ** . I note that overloaded operators in C # are not idiomatic, so the Pow method will seem quite natural to C # users.
source share