如何在F#类中定义和使用静态变量

7 f# functional-programming

有没有办法让F#类中的可变静态变量与C#类中的静态变量相同?

Chr*_*ith 14

你使用static let绑定(注意:虽然需要一些时间,它没有太多功能):

type StaticMemberTest () =

    static let mutable test : string = ""

    member this.Test 

        with get() = 
            test <- "asdf"
            test
Run Code Online (Sandbox Code Playgroud)