2011年6月22日
摘要: using System;using System.IO;using System.Collections;using System.Runtime.Serialization;// Note: When building this code, you must reference the// System.Runtime.Serialization.Formatters.Soap.dll assembly.using System.Runtime.Serialization.Formatters.Soap;class App { [STAThread] static void Main() 阅读全文
posted @ 2011-06-22 22:18 上校 阅读(352) 评论(0) 推荐(0)
摘要: (一)有时候需要将C#中某一个结构很复杂的类的对象存储起来,或者通过网路传输到远程的客户端程序中去, 这时候用文件方式或者数据库方式存储或者传送就比较麻烦了,这个时候,最好的办法就是使用串行和解串(Serialization & Deserialization). .NET中串行有三种,BinaryFormatter, SoapFormatter和XmlSerializer. 其中BinaryFormattter最简单,它是直接用二进制方式把对象(Object)进行串行或反串,他的优点是速度快,可以串行private或者protected的member, 在不同版本的。NET中都兼容, 阅读全文
posted @ 2011-06-22 22:16 上校 阅读(370) 评论(0) 推荐(0)
摘要: /// <summary> /// 序列化DataTable /// </summary> /// <param name="pDt">包含数据的DataTable</param> /// <returns>序列化的DataTable</returns> public static string SerializeDataTableXml(DataTable pDt, string pdtname) { // 序列化DataTable pDt.TableName = pdtname; StringBui 阅读全文
posted @ 2011-06-22 11:47 上校 阅读(384) 评论(0) 推荐(0)