引用dllprotobuf-net.rar

 

/// <summary>

/// buf序列化

/// </summary>

public static String SerializerBuf<T>(T obj)

{

MemoryStream ms = new MemoryStream();

ProtoBuf.Serializer.Serialize<T>(ms, obj);

return Convert.ToBase64String(ms.ToArray());

}

 

/// <summary>

/// buf反序列化

/// </summary>

/// <typeparam name="T"></typeparam>

/// <param name="base64String"></param>

/// <returns></returns>

public static T DeSerializerBuf<T>(string base64String)

{

MemoryStream ms = new MemoryStream(Convert.FromBase64String(base64String));

return ProtoBuf.Serializer.Deserialize<T>(ms);

}

相关文章:

  • 2022-12-23
  • 2021-05-21
  • 2021-05-24
  • 2022-02-13
  • 2021-06-11
  • 2021-10-26
  • 2022-12-23
  • 2021-12-25
猜你喜欢
  • 2021-08-03
  • 2021-12-24
  • 2021-06-10
  • 2022-12-23
  • 2021-10-28
  • 2022-12-23
  • 2022-01-26
相关资源
相似解决方案