Q:

Xml Serialization of a Collection with Properties

I have this simple class:
public class MappingCollection<T> : List<T>
{
    private int _declaredTotal = -1;
    public int DeclaredTotal { get { return _declaredTotal; } set { _declaredTotal = value; } }
}

And I'm using it inside another class, called "Mapping". Instances of "Mapping" get serialized to xml. Every other property of Mapping gets serialized correctly (classes, scalar properties etc).
When it serializes this custom list that I created, the list elements get serialized correctly, but the "DeclaredTotal" property does not. As it is, it's always serialized as -1, if I remove the default value it's always serialized as 0.
I don't get any runtime error, so I don't really know where the problem resides.
Anyone knows how to solve this strange behavior?

A:

If you find no solution you can try  to use a different xml-serializer like sharpserializer or DataContractSerializer

