Binary deserialize a custom object in C#

Poster
Posted by Poster under C# category on | Views : 5564
To binary deserialize a custom object in C#, use following code snippet

private object BinaryDeSerializeAnObject(Stream stream)
{
object obj = null;
// Construct a binary formatter
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

// Deserialize the stream into object
obj = formatter.Deserialize(stream);


return obj;
}


Call above method like

BinaryDeSerializeAnObject(myCustomObjectInStream);


Thanks

Comments or Responses

Login to post response