从F#实现C#相等运算符

Dan*_*iel 8 f# equality operator-overloading

是否有可能为F#中的C#相等(==)运算符提供实现?

编辑:

这段代码:

static member (=) (left : Foo, right : Foo) =
Run Code Online (Sandbox Code Playgroud)

生成编译器警告:

The name '(=)' should not be used as a member name. To define equality semantics for a type, override the 'Object.Equals' member. If defining a static member for use from other CLI languages then use the name 'op_Equality' instead.

后一部分解决了我试图做的事情.知道为什么op_Equality简单地受到青睐(=)

Dan*_*iel 8

弄清楚了:

type Foo() =
    static member op_Equality (left : Foo, right : Foo) =
Run Code Online (Sandbox Code Playgroud)