相关疑难解决方法(0)

如何动态添加XmlInclude属性

我有以下课程

[XmlRoot]
public class AList
{
   public List<B> ListOfBs {get; set;}
}

public class B
{
   public string BaseProperty {get; set;}
}

public class C : B
{
    public string SomeProperty {get; set;}
}

public class Main
{
    public static void Main(string[] args)
    {
        var aList = new AList();
        aList.ListOfBs = new List<B>();
        var c = new C { BaseProperty = "Base", SomeProperty = "Some" };
        aList.ListOfBs.Add(c);

        var type = typeof (AList);
        var serializer = new XmlSerializer(type);
        TextWriter w = …
Run Code Online (Sandbox Code Playgroud)

.net c# xml-serialization xmlinclude

25
推荐指数
2
解决办法
2万
查看次数

标签 统计

.net ×1

c# ×1

xml-serialization ×1

xmlinclude ×1