I was curious to know if there was an easy way to do the following.
public class Person
{
public String Name{ get; set; }
public void Load(Stream stream)
{
this = new XmlSerializer(GetType()).Deserialize(stream) as Person;
}
public void Save(Stream stream)
{
new XmlSerializer(GetType()).Serialize(stream, this);
}
}
I realize that this will not compile; however, I find that sometimes I wish to assign an object from within itself. (i.e. the object undergoes a massive change and I wish to instead of changing each value, simply "reset" the object by calling its constructor and setting the object to its new version).
Any thoughts on how to do this?
voidreturn a newly created instance.