Tôi có mã C# sau.Cách sử dụng đối tượng C# từ F #?
namespace MyMath {
public class Arith {
public Arith() {}
public int Add(int x, int y) {
return x + y;
}
}
}
Và tôi đã đưa ra mã F # có tên testcs.fs để sử dụng đối tượng này.
open MyMath.Arith
let x = Add(10,20)
Khi tôi chạy lệnh sau
fsc -r:MyMath.dll testcs.fs
tôi đã thông báo lỗi này.
/Users/smcho/Desktop/cs/namespace/testcs.fs(1,13): error FS0039: The namespace 'Arith' is not defined /Users/smcho/Desktop/cs/namespace/testcs.fs(3,9): error FS0039: The value or constructor 'Add' is not defined
Điều gì có thể sai? Tôi đã sử dụng mono cho môi trường .NET.
Nó hoạt động tốt. Cảm ơn. – prosseek