快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

xmlSerializer怎么在C#项目中使用

xmlSerializer怎么在C#项目中使用?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

潮州网站建设公司成都创新互联公司,潮州网站设计制作,有大型网站制作公司丰富经验。已为潮州近千家提供企业网站建设服务。企业网站搭建\外贸网站制作要多少钱,请找那个售后服务好的潮州做网站的公司定做!

public class Entity
{
    public Entity()
    {
    }
    public Entity(string c, string f)
    {
      name = c;
      school = f;
    }
    public string name;
    public string school;
}

使用时声明

List entityList=null;
XmlSerializer xs = new XmlSerializer(typeof(List));

读入

using (StreamReader sr = new StreamReader(configPath))
{
   entityList = xs.Deserialize(sr) as List;
}

输出

using (StreamWriter sw = File.CreateText(configPath))
{
  xs.Serialize(sw, entityList);
}

对应的xml



 
  Alice
  SJTU
 
 
  Cici
  CSU
 
 
  Zero
  HIT
 

关于 xmlSerializer怎么在C#项目中使用问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注创新互联行业资讯频道了解更多相关知识。


网页题目:xmlSerializer怎么在C#项目中使用
文章起源:http://6mz.cn/article/jgcegd.html

其他资讯