I have a class that contains a list of objects. I need to specify both the order that the list appears as well as the name of the elements in the list.
i.e.
public class outer
{
[XmlElement(Order=0)]
public string A {get; set;}
public List<WronglyNamedObjectType> MyList = new List<WronglyNamedObjectType>();
[XmlElement(Order=2)]
public string C{get; set;}
}
I want to be able to
1) apply an order to how the serialization occurs such that MyList comes between A and C when 'outer' is serialized.
2) be able to tell the serializer to name the elements contained in the list something other than 'WronglyNamedOjbectType'.
1 is satisfied by placing [XmlElement(Order=1)] above the property
2 is satisfied by placing [XmlArrayItem("BetterName")] above the property
For some unknown and undefined reason, both are not allowed?
Any ideas?