using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
//引用iO命名空间用到内存流
using System.Threading;
namespace Test
{
class Program
{
static void Main(string[] args)
{
//序列化和反序列化
string pp = "对象";
object obj = (object)pp;
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter Binaryf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
System.IO.MemoryStream Memorys = new System.IO.MemoryStream();
Binaryf.Serialize(Memorys, obj);
Memorys.Seek(0, SeekOrigin.Begin);
object newobj = Binaryf.Deserialize(Memorys);
Console.WriteLine((string)newobj);
Memorys.Close();
Console.ReadLine();
}
}
}
序列化和反序列化
最新推荐文章于 2023-10-17 15:34:36 发布