How to rename XML attribute that generated after serializing List of objects

后端 未结 4 1148
我寻月下人不归
我寻月下人不归 2020-12-01 12:24

I am serializing List of objects List , and XmlSerializer generates attribute, I want rename it or rem

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 12:47

    Change the following line from:

    XmlSerializer serializer = new XmlSerializer(typeof(List));
    

    To:

    XmlRootAttribute root = new XmlRootAttribute("TestObjects");     
    
    XmlSerializer serializer = new XmlSerializer(typeof(List), root);
    

    It should work.

提交回复
热议问题