重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

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://cqcxhl.com/article/jgcegd.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP