Pregunta

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 }
¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top