How to use C# object from F#?

后端 未结 3 1005
温柔的废话
温柔的废话 2020-12-11 00:37

I have the following C# code.

namespace MyMath {
    public class Arith {
        public Arith() {}
        public int Add(int x, int y) {
            return         


        
3条回答
  •  情深已故
    2020-12-11 01:26

    try

    open MyMath
    let arith = Arith() // create instance of Arith
    let x = arith.Add(10, 20) // call method Add
    

    Arith in your code is class name, you cannot open it like namespace. Possibly you are confused with ability to open F# modules so its functions can be used without qualification

提交回复
热议问题