0

I have a class being serialized with the following property:

[XmlAttribute("Phone Number")]
public string PhoneNumber{ get; set; }

public bool ShouldSerializePhoneNumber()
{
    return !string.IsNullOrEmpty(PhoneNumber);
}

However, if the Phone Number is left empty, it's still serializing it. (phonenumber="").

PhoneNumber is set to string.Empty when my object is being created. Is there a step I'm missing?

binncheol
  • 1,393
  • 4
  • 22
  • 38
  • 1
    Possible duplicate of [Xml serialization - Hide null values](http://stackoverflow.com/questions/5818513/xml-serialization-hide-null-values) – Jason Mar 29 '17 at 13:57
  • see the note about XmlAttribute in the linked question – Jason Mar 29 '17 at 13:58

0 Answers0