F#属性的快捷语法? [英] F# Shortcut Syntax for Properties?
本文介绍了F#属性的快捷语法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有关常规属性getter/setter语法
For the normal property getter/setter syntax
let mutable myInternalValue
member this.MyProperty
with get() = myInternalValue
and set(value) = myInternalValue <- value
是否有快捷方式,类似于C#中的以下内容?
is there a shortcut, similar to the following in C#?
someType MyProperty { get; set; }
如果有一个,我似乎找不到它...
If there is one, I seem to be unable to find it...
推荐答案
F#3具有自动实现的属性,因此您可以在不声明背景字段的情况下声明属性.
F# 3 has auto-implemented properties so you can declare properties without declaring the backing field.
示例取自MSDN上的属性(F#):
Example taken from Properties(F#) on MSDN:
type MyClass() =
member val MyProperty = "" with get, set
这篇关于F#属性的快捷语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文