亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

c#泛型序列化對(duì)象為字節(jié)數(shù)組的示例

 更新時(shí)間:2014年04月22日 10:43:29   作者:  
這篇文章主要介紹了c#泛型序列化對(duì)象為字節(jié)數(shù)組的示例,需要的朋友可以參考下

序列化對(duì)象為字節(jié)數(shù)組

復(fù)制代碼 代碼如下:

using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
        protected byte[] Serialize<T>(T t)
        {
            MemoryStream mStream = new MemoryStream();
            BinaryFormatter bFormatter = new BinaryFormatter();
            bFormatter.Serialize(mStream, t);
            return mStream.GetBuffer();
        }

反序列化字節(jié)數(shù)組為對(duì)象

復(fù)制代碼 代碼如下:

using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
        protected T Deserialize<T>(byte[] b)
        {
            BinaryFormatter bFormatter = new BinaryFormatter();
            return (T)bFormatter.Deserialize(new MemoryStream(b));
        }

相關(guān)文章

最新評(píng)論