Serialization
Serialization is the process of converting an object into a stream of data so that it can be made transmittable over the network
Serialization
Serialization is the process of converting an object into a stream of data so that it can be easily transmittable over the network
if you want to store an object (or multiple objects) in a file for later retrieval,
you store the output of serialization. The next time you want to read the objects, you
call the deserialization methodsTo Serialize
* Create an object Stream
* Create a BinaryFormatter
* Call the BinaryFormatter.Serialize method to serialize
Dim data As String = "This must be stored in a file or folder"
Dim fs As FileStream = New FileStream("SerializedString.Data", _
FileMode.Create)
Dim bf As BinaryFormatter = New BinaryFormatter
bf.Serialize(fs, data)
fs.Close
If you open the file in a notepad you can notice the contents of your file surrounded by binary numbersDeSerialiazation
Deserialization is the process of converting a previously serialized sequence of bytes into an objectTo Deserialize
* Create an object Stream to read a serialized output
* Create a BinaryFormatter object
* Create an object to store a Deserialized data
* USE the BinaryFormatter.Deserialize method to deserialize the object
Dim fs As FileStream = New FileStream("SerializedString.Data", FileMode.Open)
Dim bf As BinaryFormatter = New BinaryFormatter
Dim data As String = ""
data = DirectCast(bf.Deserialize(fs), String)
fs.Close
Console.WriteLine(data)