欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#反序列化到類的實(shí)現(xiàn)方法

 更新時(shí)間:2015年05月20日 09:47:41   作者:依山帶水  
這篇文章主要介紹了C#反序列化到類的實(shí)現(xiàn)方法,涉及C#反序列化的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了C#反序列化到類的實(shí)現(xiàn)方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using 二進(jìn)制序列化;
namespace 反序列化
{
  class Program
  {
    static void Main(string[] args)
    {
      BinaryFormatter bf = new BinaryFormatter();
      using (FileStream fs = new FileStream ("person.bin",FileMode.Open))
      {
        object obj = bf.Deserialize(fs);
        People p = (People)obj;
        Console.WriteLine("姓名:{0}\t年齡:{1}",p.Name ,p.Age);
      }
      Console.WriteLine("反序列化完畢!");
      Console.ReadKey();
    }
  }
}

這里注意反序列化時(shí)需要引用People類所在的程序集

希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論