public byte[] Serialize() { byte[] bytes; using (var memstream = new MemoryStream()) { ProtoBuf.Serialize(this, memstream); memstream.Seek(0, SeekOrigin.Begin); bytes = new byte[memstream.Length]; memstream.Read(bytes, 0, bytes.Length); } return(bytes); }