Represents an attribute that specifies the derived types that the System.Xml.Serialization.XmlSerializer can place in a serialized array.
See Also: XmlArrayItemAttribute Members
The System.Xml.Serialization.XmlArrayItemAttribute belongs to a family of attributes that controls how the System.Xml.Serialization.XmlSerializer serializes or deserializes an object. For a complete list of similar attributes, see Attributes That Control XML Serialization.
You can apply the System.Xml.Serialization.XmlArrayItemAttribute to any public read/write member that returns an array, or provides access to one. For example, a field that returns an array of objects, a collection, an ArrayList, or any class that implements the IEnumerable interface.
The System.Xml.Serialization.XmlArrayItemAttribute supports polymorphism--in other words, it allows the System.Xml.Serialization.XmlSerializer to add derived objects to an array. For example, suppose a class named Mammal is derived from a base class named Animal. Further suppose that a class named MyAnimals contains a field that returns an array of Animal objects. To allow the System.Xml.Serialization.XmlSerializer to serialize both the Animal and Mammal type, apply the System.Xml.Serialization.XmlArrayItemAttribute to the field twice, each time specifying one of the two acceptable types.
You can apply multiple instances of the System.Xml.Serialization.XmlArrayItemAttribute or System.Xml.Serialization.XmlElementAttribute to specify types of objects that can be inserted into the array.
The serialization of a field or property that returns an interface or array of interfaces is not supported.
For more information about using attributes, see Extending Metadata Using Attributes.
You can use the word XmlArrayItem in your code instead of the longer System.Xml.Serialization.XmlArrayItemAttribute.