Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between BinaryWriter and BinaryFormatter.Serialize?

I'm new to object serialization, and in the course of my learning how to read from and write to a file (deserialize and serialize) using BinaryFormatter, I came across BinaryReader and BinaryWriter, which seemed to be doing the same thing.

Is there some subtle difference between BinaryFormatter.Serialize() and BinaryWriter? Or is BinaryWriter just a more compact way performing the the same action as BinaryFormatter.Serialize()?

like image 682
AustinC Avatar asked Nov 22 '16 19:11

AustinC


1 Answers

BinaryWriter is used to write primitive types in binary to a stream and supports writing strings in a specific encoding. BinaryFromatter is responsible for serializing an entire object or graph of connected objects into binary format. So, I suppose you can say BinaryWriter is a much more elementary form of something like BinaryFormatter.

I got this information here: BinaryWriter & BinaryFormatter

like image 162
Corey Berigan Avatar answered Sep 23 '22 11:09

Corey Berigan