更新时间:2022-11-27 22:43:54
您应该在这里使用封装而不是继承.
You should use encapsulation, rather than inheritance here.
class TopLevelBlock
{
readonly XElement doc;
TopLevelBlock(string name)
{
doc = new XElement((XName)name);
doc.SetAttributeValue("someAttribute","");
}
public int someAttribute
{
get
{
return int.Parse(doc.Attribute("someAttribute").Value);
}
set
{
doc.SetAttributeValue("someAttribute", value.ToString());
}
}
}
也许是XML序列化.
David