change how XmlSerializer serializes empty elements
问题 I am using the XmlSerializer. It serializes the object just fine but the client requires required empty elements to be in this format <star:Confirm/> . The serializer instead serializes the empty elements to <star:Confirm></star:Confirm> is there a way to change it to serialize the way the client requires. 回答1: After trying different things I accidentally happened upon the solution. I set the XmlElementAttribute.IsNullable to true like the previous answer suggested. [System.Xml.Serialization