序列化时是否可以避免列表属性标记?
//[Serializable()] - removed, unnecessary public class Foo { protected ListfooBars = new List (); public virtual List FooBars { get { return fooBars; } set { fooBars = value; } } } // [Serializable()] - removed, unnecessary public class FooBar { public int MyProperty { get; set; } }
序列化Foo给出(评论除外):
7 9
通缉输出:
7 9
添加:
[System.Xml.Serialization.XmlElement("FooBar")] public virtual ListFooBars { get { return fooBars; } set { fooBars = value; } }
结果是
7 76 67