开发者

Can a static member be overloaded?

开发者 https://www.devze.com 2022-12-30 18:58 出处:网络
type A() = static member B() = () static member B(x) = B() //ERROR: Th开发者_StackOverflowe value or constructor \'B\' is not defined
type A() =
    static member B() = ()
    static member B(x) = B() //ERROR: Th开发者_StackOverflowe value or constructor 'B' is not defined


When refering to a static member in F#, you need to use the full name (including the name of the type). The F# compiler doesn't automatically look for static members of the current class.

The following should work:

type A() = 
    static member B() = () 
    static member B(x) = A.B()
0

精彩评论

暂无评论...
验证码 换一张
取 消