开发者

XmlElementName - Change during runtime

I am implementing a class object that is serializable.

something like this:

  StringWriter sw = new StringWriter();
        XmlSerializerNamespaces ns = new XmlSerializerN开发者_运维百科amespaces();
        ns.Add("", "");

        System.Xml.Serialization.XmlSerializer x = 
              new System.Xml.Serialization.XmlSerializer(this.GetType());
        x.Serialize(sw, this,ns);

        return sw.ToString();

I want the child class/objects to have different names depending on a flag. is there a ways to change the ElementName of the class prop. during run time without write a custom WriteXml?


Yes, but you won't like it. IXmlSerializable

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜