Wednesday, February 16, 2005

Controlling Serailzation of Arrays

Just a quick note on controlling serialization of Arrays... Arrays' serialization is done in a little different way than any other standard datatypes.. There are special attributes available in System.Xml.Serialization which can be used for Arrays.

Generally we are used to using <XmlElement("tagName")> {VB} or [XmlElement("tagName")]{C#} on properties/members of our class... If these properties/members are arrays then the XmlElement attribute will remove the tree structure and convert it into a flat list...


instead of

If you would want to get the above structure for your Xml serialization, you would have to use following Attributes

<XmlArray("tagName"), XmlArrayItem("itemTag")> {VB} or [XmlArray("tagName"), XmlArrayItem("itemTag")] {C#}

There are many other small details related to attributes etc which you can find at MSDN... Click Here

1 comment:

Mary Anne Martin said...

Thanks for this great post. You've got some really good info in your blog. If you get a chance, you can check out my blog on
{mcsd} at

Mary Anne Martin