我得到了将对象序列化为文件的 Protobuf-net 的源代码。
var person = new Person {
Id = 12345, Name = "Fred",
Address = new Address {
Line1 = "Flat 1",
Line2 = "The Meadows"
}
};
using (var file = File.Create("person.bin")) {
ProtoBuf.Serializer.Serialize(file, person);
}
但是假设我有两个要序列化为单个文件的 Person 实例。我怎样才能做到这一点?