Protocol Buffers is the name of the binary serialization format used by Google for much of their data communications. It is designed to be: small in size - efficient data storage (far smaller than xml) cheap to process - both at the client and server platform independent - portable between different programming architectures extensible - to add new data to old messages. protobuf-net is a .NET implementation of this, allowing you to serialize your .NET objects efficiently and easily. It is compatible with most of the .NET family, including .NET 2.0/3.0/3.5/4.0, .NET CF 2.0/3.5, Mono 2.x, Silverlight, etc.
See the following samples where you can use it.
Step 1: Install protobuff
To install protobuf-net, run the following command in the Package Manager Console
PM> Install-Package protobuf-net
Step 2: Create the Data Models
Unlike XmlSerializer, the member-names are not encoded in the data - instead, you must pick an integer to identify each member. Additionally, to show intent it is necessary to show that we intend this type to be serialized. See the following sample.
Notes for Identifiers
- they must be positive integers
- they must be unique within a single type
- but the same numbers can be re-used in sub-types if inheritance is enabled
- the identifiers must not conflict with any inheritance identifiers lower numbers take less space - don't start 100,000,000
- the identifier is important; you can change the member-name, or shift it between a property and a field, but changing the identifier changes the data
Step 3: Serialize to stream
Step 3: Serialize and write to a file.
for more information in protobuf visit here
Happy Coding !!!