Why XML-Serializable class need a parameterless constructor

后端 未结 4 1849
盖世英雄少女心
盖世英雄少女心 2020-11-22 05:11

I\'m writing code to do Xml serialization. With below function.

public static string SerializeToXml(object obj)
{
    XmlSerializer serializer = new XmlSeria         


        
4条回答
  •  逝去的感伤
    2020-11-22 05:22

    First of all, this what is written in documentation. I think it is one of your class fields, not the main one - and how you want deserialiser to construct it back w/o parameterless construction ?

    I think there is a workaround to make constructor private.

提交回复
热议问题