Hello,
I've got an xml stream that I'd need to deserialize into an instance of a
given class A. I'd like to create an instance method on class A (method
Deserialize) that takes this XML stream as input and deserializes it "into
itself" ... in other words I'd like it to "fill" the instance of class A on
which the method has been called instead of returning another instance of
class A.
The code below gives a good idea of what I'd like:
public class A
{
public void Deserialize(MemoryStream stream)
{
XmlSerializer serializer = new XmlSerializer(typeof(A));
// the following line of code obviously does not work since this is
readonly
// but it gives a good idea of what I'd like to do
this = serializer.Deserialize(stream);
}
}
How can I accomplish this without having to manually "load" all the class
fields???
Bob Rock