문제

In F#, what is the correct syntax to specify a DefaultValue on the DataContract? For example, in the code below, how do I set the default value for address to "".

[<DataContract>]
type Geocode = 
    { [<field: DataMember(Name = "type")>]
    typeX : string 
    [<field: DataMember(Name = "address")>]
    address : string }
도움이 되었습니까?

해결책

Records don't support default values for fields. You'll have to use a class and the [<DefaultValue>] attribute. You can read more in the MSDN article on Explicit Fields.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top