I just recently started playing with XML and the XML Serializer class. However, when serializing certain classes I encountered some strange results.

If I create a strongly typed collection and serialize it, it works perfectly fine, no problems there, the problem arises when I want to add an extra property to the collection class, such as Name or something. This extra property obviously can't be an element inside a collection class, however, I'm unable to make it an attribute either.

Is it possible to have a collection class that has some additional properties that can be used to like distinguish that instance from another like a Name property, have the additional properties serialized as attributes of that collection?

If not, what's the best way of doing it? Because I also put collections inside collections, hence why I add these extra properties to the collection, because it's the most logical place to put them.