DataSet序列化,这段代码研究研究、学习学习。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary; namespace PromTest
{ class Program
{
static void Main(string[] args)
{
DataSet ds = new DataSet();
DataTable table = new DataTable("tab1");
ds.Tables.Add(table);
table.Columns.Add(new DataColumnEx() { ItemCategory = "测试" }); BinSerialize(ds);
object obj = BinDeserialize(); if (((DataSet)obj).Tables[].Columns[] is DataColumnEx)
{
Console.WriteLine((((DataSet)obj).Tables[].Columns[] as DataColumnEx).ItemCategory);
} Console.Read();
} static void BinSerialize(object info)
{ using (Stream stream = new FileStream("c:\\a.bin", FileMode.Create, FileAccess.Write))
{
BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(stream, info);
}
} static object BinDeserialize()
{
using (Stream stream = new FileStream("a.bin", FileMode.Open, FileAccess.Read))
{
BinaryFormatter bf = new BinaryFormatter(); return bf.Deserialize(stream);
}
}
} public class DataColumnEx : DataColumn
{
public string ItemCategory
{ get; set; }
}
}

参考

  http://bbs.csdn.net/topics/390702495

*DataSet序列化,这段代码研究的更多相关文章

  1. 一段markdown编辑器代码研究

    一段markdown编辑器代码研究 说明 代码在 https://github.com/dukeofharen/markdown-editor 之所以选择这个来分析是一方面是因为它的代码结构比较简单, ...

  2. dedecms代码研究二

    dedecms代码研究(2)从index开始现在继续,今天讲的主要是dedecms的入口代码.先打开index.PHP看看里面是什么吧.打开根目录下的index.php嗯映入眼帘的是一个if语句.检查 ...

  3. js中闭包来实现bind函数的一段代码的分析

    今天研究了一下bind函数,发现apply和call还可以有这样的妙用,顺便巩固复习了闭包. var first_object = { num: 42 }; var second_object = { ...

  4. Ningx代码研究.

    概述 研究计划 参与人员 研究文档 学习emiller的文章 熟悉nginx的基本数据结构 nginx 代码的目录结构 nginx简单的数据类型的表示 nginx字符串的数据类型的表示 内存分配相关 ...

  5. VBA_50段代码总结

    ''                                                          30个有用的VBA代码 '目录: '1--合理使用数组:'2--一次保存并关闭所 ...

  6. 评《撸一段 SQL ? 还是撸一段代码? 》

    最近看到一篇博客<撸一段 SQL ? 还是撸一段代码?>,文章举例说明了一个连表查询使用程序code来写可读性可维护性更好,但是回帖意见不一致,我想作者在理论层面没有做出更好的论述,而我今 ...

  7. Unity 延迟执行一段代码的较为优雅的方式

    在Unity中,延时执行一段代码或者一个方法或者几个方法的情况非常普遍. 一般会用到Invoke和InvokeRepeating方法.顾名思义,第一个是执行一次,第二个是重复执行. 看下定义: voi ...

  8. μC/OS-Ⅲ中的临界段代码

    临界段代码(critical sections),也叫临界区(critical region),是指那些必须完整连续运行,不可被打断的代码段.μC/OS-Ⅲ系统中存在大量临界段代码.采用两种方式对临界 ...

  9. JavaScript-navigator_userAgent-编写一段代码能够区分浏览器的主流和区分

    1 userAgent:包含浏览器名称和版本号的字符串 <!DOCTYPE html> <html> <head lang="en"> < ...

随机推荐

  1. C++全排列 next_permutation

    全排列函数  next_permutation 这是C++的STL中专门用来排列的函数(可以自动处理存在重复数据集的排列问题) 使用时要加上头文件 #include <algorithm> ...

  2. 使用Spring CROS解决项目中的跨域问题

    CROS(Cross-Origin Resource Sharing) 用于解决浏览器中跨域请求的问题.简单的Get请求可以使用JSONP来解决,而对于其它复杂的请求则需要后端应用的支持CROS.Sp ...

  3. CI 框架 伪静态设置 去掉index.php

    .htaccess文件修改 DirectoryIndex index.php RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME ...

  4. 使用Python快速实现简单的人脸检测

    最近有个比较要好的朋友问我能不能从监控视频里识别到从监控跟前经过的指定的人.因为他们单位的监控室经常要花大量的人力跟时间去找某个人在哪个位置出现过的证据.听起来像是一份比较有挑战性的任务,就答应他试试 ...

  5. python技巧 — pip install 错误,超时

    jieba库安装失败   pip install -i https://pypi.tuna.tsinghua.edu.cn/simple jieba wordcloud库安装失败 pip instal ...

  6. 【LEETCODE】42、922. Sort Array By Parity II

    package y2019.Algorithm.array; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * ...

  7. Spring Cloud Zuul路由规则动态更新

    背景  Spring Cloud Zuul 作为微服务的网关,请求经过zuul路由到内部的各个service,由于存在着新增/修改/删除服务的路由规则的需求,zuul的路由规则的动态变更功能 提供了 ...

  8. bat 设置多个静态ip

    @echo off REM 本地连接名称 set NetName="本地连接 2" REM 默认IP netsh interface ipv4 set address name=% ...

  9. 分享-SpringCloud微服务架构图

    1: 为大家分享一张SpringCloud微服务通用架构图 ​标题 此图仅供参考: 需要原图的同学请移步 >>>>>>>>> 这里 如有不合理的地 ...

  10. 从MVC -> MVVM ? 开发模式

    MVVM 到底是什么? view :由 MVC 中的 view 和 controller 组成,负责 UI 的展示,绑定 viewModel 中的属性,触发 viewModel 中的命令: viewM ...