字节数组转对象

/// <summary>
/// 字节数组转对象
/// </summary>
/// <param name="buff"></param>
/// <returns></returns>
public static object Bytes2Object(byte[] buff)
{
object obj;
using (MemoryStream ms = new MemoryStream(buff))
{
IFormatter iFormatter = new BinaryFormatter();
obj = iFormatter.Deserialize(ms);
}
return obj;
}

posted @ 2020-02-27 20:03  api-80  阅读(529)  评论(0编辑  收藏  举报