using pb = global::Google.Protobuf;
private static byte[] FormatToBinary(T obj)
{
using (MemoryStream stream = new MemoryStream())
{
pb::CodedOutputStream s = new pb::CodedOutputStream(stream);
obj.WriteTo(s);
//s.Flush(); //once I add it,the message could not be sent any more
return stream.ToArray();
}
}
the result return an array with 0 element.
once I add s.Flush(); the value will be changed,while the message could not be sent any more.
what I want to do is just converting message data to byte array in protobuf encoding with proto3