2009-06-20 112 views

回答

13

這裏是一個簡短的腳本,定義並使用一個私有的靜態成員:

type MyClass = 
    static member private MyPrivateMember() = printfn "MyPrivateMember()" 

    static member MyMember() = MyClass.MyPrivateMember() 

MyClass.MyMember() // MyPrivateMember() 
5

一種替代方案:

type MyClass() = 
    static let myPrivateMethod() = 
     printfn "This is inaccessible outside the class."