[Serializable]
public class CardItemInfo
{
private int lineWidth;//线宽
private CardItemInfo childCardItemInfo;
public int LineWidth
{
get { return lineWidth; }
set
{
lineWidth = value;
}
}
public int ChildCardItemInfo
{
get { return childCardItemInfo; }
set
{
childCardItemInfo = value;
}
}
}

定义列表

private static List<CardItemInfo> listItemInfo=new List<CardItemInfo>();

序列化到XML

public static bool SaveXml()
{
CardItemInfo cardItemInfo=new CardItemInfo();
cardItemInfo.LineWidth = ;
CardItemInfo childCardItemInfo=new CardItemInfo();
childCardItemInfo.LineWidth = ;
cardItemInfo.ChildCardItemInfo = childCardItemInfo;
listItemInfo.Add(cardItemInfo);
Stream fStream = new FileStream(System.Windows.Forms.Application.StartupPath + @"\test11.xml", FileMode.Create);
XmlSerializer xmlFormat = new XmlSerializer(typeof(List<CardItemInfo>));
xmlFormat.Serialize(fStream, listItemInfo);//序列化对象
return false;
}

从XML反序列化

public static bool LoadFromXml(String fileName)
{
try
{
System.IO.Stream fStream = new FileStream(fileName, FileMode.Open);
XmlSerializer xmlFormat = new XmlSerializer(typeof(List<CardItemInfo>));
listItemInfo = (List<CardItemInfo>)xmlFormat.Deserialize(fStream);
fStream.Close();
MessageBox.Show("OK"); }
catch (Exception e)
{
MessageBox.Show(e.Message);
return false;
}
return true;
}

博客资源:QQ群616945527,博客相关资源,同名文件。

C#复杂类型序列化的更多相关文章

  1. Spring MVC+Fastjson之时间类型序列化

    时间类型序列化: 注意红色代码,必须引入fastjson的JSONField类,而非其它. import com.alibaba.fastjson.annotation.JSONField; @Ent ...

  2. C# dynamic类型序列化和反序列化之Newtonsoft.Json

    原文:C# dynamic类型序列化和反序列化之Newtonsoft.Json 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u011127019/ ...

  3. 【SpringBoot】 中时间类型 序列化、反序列化、格式处理

    [SpringBoot] 中时间类型 序列化.反序列化.格式处理 Date yml全局配置 spring: jackson: time-zone: GMT+8 date-format: yyyy-MM ...

  4. 那些年一起踩过的坑 — Date类型序列化的问题

      坑在哪里?        序列化 和 反序列化 的时候对Date字段的格式设置不一致        例如:将Java bean序列化成Json string的时候 格式为 yyyy-MM-dd 解 ...

  5. C# dynamic类型序列化和反序列化之Newtonsoft.Json,动态解析远端返回的jSON数据

    一.说明 1.Newtonsoft.Json 中的Linq To Json中提供了方便的json数据查询.修改等操作. 例如:JObject,JArray 2.在JObject.FromObject( ...

  6. C# 匿名类型序列化、反序列化

    前言 现在提倡前后端分离,分离后服务全部采用接口的方式给前端提供服务,当我们处理自定义查询时必定会多表查询,而处理多表查询时我们又懒的去建view model,建的过多项目也凌乱的很,所以在dao层处 ...

  7. js switch 函数类型 序列化 转义

    switch(name){ case '1': age = 123; break; case '2': age = 456; break; default : age = 777; } 函数 func ...

  8. C#如何把XSD中HexBinary类型序列化uint类型

    xml schema中有hexBinary类型, 我们在实现C#的Serialization时,一般默认把hexBinary映射为byte[],但是有些情况我们需要把 hexBinary映射为uint ...

  9. Flink资料(4) -- 类型抽取和序列化

    类型抽取和序列化 本文翻译自Type Extraction and Serialization Flink处理类型的方式比较特殊,包括它自己的类型描述,一般类型抽取和类型序列化框架.该文档描述这些概念 ...

随机推荐

  1. LY tomcat 的闪退问题

    http://www.cnblogs.com/1693977889zz/archive/2018/04/06/8726920.html 在bin文件夹里打开此文件setclasspath.bat 举例 ...

  2. webpack4.x相关笔记整理

    概念 Webpack是一个模块打包机,它可以将我们项目中的所有js.图片.css等资源,根据其入口文件的依赖关系,打包成一个能被浏览器识别的js文件.能够帮助前端开发将打包的过程更智能化和自动化. W ...

  3. 基于C#.NET的高端智能化网络爬虫(一)(反爬虫哥必看)

    前两天朋友发给我了一篇文章,是携程网反爬虫组的技术经理写的,大概讲的是如何用他的超高智商通过(挑衅.怜悯.嘲讽.猥琐)的方式来完美碾压爬虫开发者.今天我就先带大家开发一个最简单低端的爬虫,突破携程网超 ...

  4. 05 Zabbix triggers--action--event

    点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 05 Zabbix triggers--action--event 动作action: 在配置好监 ...

  5. JavaScript 获得 坐标

    <!DOCTYPE html> <html> <head> <title>location</title> <meta http-eq ...

  6. 通过 powershell 配置 IIS

    1. 设置iis pool: cls Import-Module WebAdministration Get-ChildItem IIS:\apppools | ForEach-Object{     ...

  7. LoadRunner断言:正确结果有多种情况

    用过lr的都知道,我们可以用web_reg_find这个注册函数判断某个请求的返回中是否有我们要找的内容. 但是,如果正常的情况有多种,该如何断言呢? 设置多个检查点 把每个检查点获取到的结果数量相加 ...

  8. Android log 方法

    package test; public abstract class Logger { private static Class<? extends Logger> mLoggerCla ...

  9. yiming

      关于双城 专家团队 总裁专栏 双城荣誉 诚聘英才 双城著作移民服务 移民专题 移民专刊 移民百科 成功案例 联系我们   澳大利亚 匈牙利 美国 加拿大 欧洲 瓦努阿图 双城集团 双城地产 君益诚 ...

  10. Arch Linux中通过AUR安装Redis Desktop Manager失败

    笔者在安装Redis Desktop Manager时出现了Failed to connect to chromium.googlesource.com port 443: Connection ti ...