1

I need to serialise a number of objects to file, so was looking to give ProtoBuf-Net a try. One requirement is that I need to be able to deserialise the objects one at a time at a later date, so my first thought was to use Serializer.SerializeWithLengthPrefix & Serializer.DeserializeWithLengthPrefix.

I then saw this SO answer which seemed to suggest that it may be possible to add the objects to a list then serialise this with a single call, but still be able to deserialise the individual objects one at a time afterwards. However I can't see the methods mentioned (SerializeItems && DeserializeItems), although it was an old article so I'm guessing these have been deprecated?

Am I best sticking with De/SerializeWithLengthPrefix, or is there a more efficient way to serialise a few thousand objects in one go, yet still be able to deserialise them one by one afterwards?

Andrew Stephens
  • 9,413
  • 6
  • 76
  • 152
  • Those methods still exist... https://github.com/protobuf-net/protobuf-net/blob/d12763cd24820c4861bf723efd3d2d26aa7fcb13/src/protobuf-net/Serializer.cs#L278 – Marc Gravell Jul 26 '19 at 16:37
  • `DeserializeItems` exists, but there is no SerializeItems. For serialization of a list/collection, I think you are meant to use `SerializeWithLengthPrefix` , which still requires iteration through the items. – Elroy Flynn Mar 08 '23 at 04:00

0 Answers0