I'm writing a serializable object that contains a collection. So, in order to be able to add and remove items from that collection, I added methods that would first convert the collection from an Array into a List, add or remove the items and then convert the List back into a Array.
public void AddElement(Element element) {
List<Element> list = new List<Element>(this.elements);
list.Add(element);
this.elements = list.ToArray();
}
Is there maybe a problem creating the List like this?
List(this.elements)
Or is it a problem, that the Array is Length is 0 at start?
EDIT1: converting from a list field also leaves an empty array.
EDIT2: XML Serialization is not wanted.