AustinC AustinC - 1 year ago 171
C# Question

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()?

Answer Source

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

I got this information here: BinaryWriter & BinaryFormatter

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download