using ProtoBuf; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SimpleClient { public static class NetBase { //序列化 public static byte[] Serizlize(T MsgObj) { using (MemoryStream ms = new MemoryStream()) { Serializer.Serialize(ms, MsgObj); byte[] data1 = ms.ToArray(); return data1; } } //反序列化 public static T DeSerizlize(byte[] MsgObj) { using (MemoryStream ms = new MemoryStream(MsgObj)) { var ds_obj = Serializer.Deserialize(ms); return ds_obj; } } } }