Deserialize Object : Serialization : File Stream C# Source Code


Custom Search

C# Source Code » File Stream » Serialization »

 

Deserialize Object








    
 

using System;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
[Serializable]
public class BookRecord {
    public String title;
    public int asin;

    public BookRecord(String title, int asin) {
        this.title = title;
        this.asin = asin;
    }
}
public class DeserializeObject {
    public static void Main() {
        FileStream streamIn = new FileStream(@"book.obj", FileMode.Open);
        BinaryFormatter bf = new BinaryFormatter();
        BookRecord book = (BookRecord)bf.Deserialize(streamIn);
        streamIn.Close();
        Console.Write(book.title + " " + book.asin);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo File Stream
» Serialization