zoukankan      html  css  js  c++  java
  • BinaryFormatter.cs

    /*
     * C# Programmers Pocket Consultant
     * Author: Gregory S. MacBeth
     * Email: gmacbeth@comporium.net
     * Create Date: June 27, 2003
     * Last Modified Date:
     * Version: 1
     */
    using System;
    using System.IO;
    using System.Runtime.Serialization.Formatters.Binary;

    namespace Client.Chapter_11___File_and_Streams
    {
        class Class1
        {
            [STAThread]
            static void Main(string[] args)
            {
                Point p1 = new Point();

                p1.xpoint = 0x1111;
                p1.ypoint = 0x2222;

                // Opens a file and serializes the object into it.
                Stream stream = File.Open("onepoint.bin", FileMode.Create);
                BinaryFormatter bformatter = new BinaryFormatter();

                bformatter.Serialize(stream, p1);
                stream.Close();

                //Read the data from a file and desiralize it
                Stream openStream = File.Open("onepoint.bin", FileMode.Open);
                Point desierializedPoint = new Point();

                desierializedPoint = (Point)bformatter.Deserialize(openStream);
            }
        }
        [Serializable()]
        class Point
        {
            public int xpoint;
            public int ypoint;
        }

    }
  • 相关阅读:
    百奥谷
    3月13日火箭VS老鹰
    百度 hi 下载地址(内测版,正式版)
    中兴u980
    2008年清明节放假通知
    cyp740703 一个女人的自白
    黄唇鱼
    3月9日火箭vs黄蜂
    3月3日火箭vs掘金
    百度hi邀请码
  • 原文地址:https://www.cnblogs.com/shihao/p/2501878.html
Copyright © 2011-2022 走看看