请教序列化问题
public static byte[] Serialize(object o)
{
BinaryFormatter formatter = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
formatter.Serialize(ms,o);
ms.Position=0;
byte[] b=ms.ToArray();
ms.Close();
return b;
}
public static object Deserialize(byte[] b)
{
BinaryFormatter formatter = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
ms.Write(b,0,b.Length);
ms.Position=0;
object o=formatter.Deserialize(ms);
ms.Close();
return o;
}
在反序列化的时候提示错误:在反序列的时候遇到结尾流