Binary serialization

In XmlSerialization, the output of the serialization is an XML file that can be easily opened by Notepad. However, as explained previously, creating a file adds to the overall storage space required by the application, which may not be desirable in all circumstances.

We also observed that if we marked any attribute with the access modifier of private, it was not copied across to the generated XML file. This may also be an issue in many cases.

In this section, we will look at an alternative approach in which we will serialize the data to a stream of bytes. This data will not be viewable like the XML file but will save us space and will deal with private attributes in a much better way.

.NET Framework provides us with ...

Get Programming in C#: Exam 70-483 (MCSD) Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.