Apologies on not being able to phrase the title more specifically but I can only explain by giving an example.
I\'m trying to build a class that serializes to the follow
Use XmlElementAttribute
to mark your collection properties.
public class Customize
{
[XmlElement("Content")]
public List Content { get; set; }
[XmlElement("Command")]
public List Command { get; set; }
}
Quick test code:
var item = new Customize() { Content = new List { new Content(), new Content() }, Command = new List { new Command(), new Command(), new Command() } };
string result;
using (var writer = new StringWriter())
{
var serializer = new XmlSerializer(typeof(Customize));
serializer.Serialize(writer, item);
result = writer.ToString();
}
Prints: