How do you use XMLSerialize for Enum typed properties in c#?

As per Darin Dimitrov’s answer – only extra thing I’d point out is that if you want control over how your enum fields are serialized out then you can decorate each field with the XmlEnum attribute.

public enum Simple
{
      [XmlEnum(Name="First")]
      one,
      [XmlEnum(Name="Second")]
      two,
      [XmlEnum(Name="Third")]
      three,
}

Leave a Comment