In a fragment of a code I’m working on, I must serialize a collection of links into an XML file. Fortunately, .NET Framework provides a quick XmlSerializer class to do the dirty job for you.
If you try to serialize a class derived from CollectionBase, the Serialize method will throw a nasty exception.
Use a container class, put the CollectionBase-derived class as a property, decorate this property with XmlArray and XmlArrayItem tags.
public class CollectionContainer
private LinkCollection _links= new ColeccionEnlaces();
public LinkCollection Links
_links = value;