F# Shortcut Syntax for Properties?

前端 未结 1 908
面向向阳花
面向向阳花 2021-02-11 18:52

For the normal property getter/setter syntax

let mutable myInternalValue

member this.MyProperty 
    with get() = myInternalValue
    and set(value) = myInterna         


        
相关标签:
1条回答
  • 2021-02-11 19:45

    F# 3 has auto-implemented properties so you can declare properties without declaring the backing field.

    Example taken from Properties(F#) on MSDN:

    type MyClass() =
        member val MyProperty = "" with get, set
    
    0 讨论(0)
提交回复
热议问题