I have a class:
public class MyClass
{
public MyClass(){}
}
I would like to be able to use an XMLSeralizer to Deserialize an XDocument directly in the constructor thus:
public class MyClass
{
private XmlSerializer _s = new XmlSerializer(typeof(MyClass));
public MyClass(){}
public MyClass(XDocument xd)
{
this = (MyClass)_s.Deserialize(xd.CreateReader());
}
}
Except I am not allowed to assign to "this" within the constructor.
Is this possible?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…