list xml deserialization
I made an xsd (xml scheme) and made a class from that using xsd.exe.
in the generated class I got an array:
but I need something that I will be able to add and remove element from it and have a variable size. ( I read the array documentation and it says that arrays *do* have variable size but I could not figure out how it is)
so I wanted to change the array to ArrayList but then I saw in the System.Xml.Serialization.Deserialize that ArrayList are not supported.
What then can I do so I can have a list in a class that I can serialize and deserialize?
Generic lists help here. From what I can tell, you can't serialize/deserialize a generic list directly (confirmation anyone? the docs are a little um, sketchy) but i've had a class inheriting from a list that's serializable.
public Main(int args)
MyList newList = new MyList();
// do the textbook serialization/deserialization for a normal class stating the type as MyList
public class MyList : List<string>
public MyList() // constructor
public string this[int index]
// getters and setters
.NET makes a little too easy sometimes, yeah you can serialize lists.
the above will make the following XML file:
public class Root
public List<string> Values;
OMG C# rules. serialization is such a pain in C++.
Thank you both.
I did not think/know about Lists.
It works great with it.