Force XML serialization of XmlDefaultValue values

前端 未结 3 1365
Happy的楠姐
Happy的楠姐 2020-12-12 00:42

Using a C# class generated from an XSD document, I can create an object, and serialize it successfully. However, some attributes have an XmlDefaultValue defined. If any ob

3条回答
  •  忘掉有多难
    2020-12-12 01:20

    I found the answer: https://msdn.microsoft.com/en-us/library/system.runtime.serialization.datamemberattribute.emitdefaultvalue%28v=vs.110%29.aspx

    Set the attribute in the DataContract like this: [DataMember(EmitDefaultValue=true)]

提交回复
热议问题