質問

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