国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > C# > 正文

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

2020-01-24 02:41:44
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

序列化對(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));
        }

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 精河县| 开封市| 中方县| 固阳县| 佛冈县| 梅河口市| 四子王旗| 临潭县| 阳西县| 桑植县| 大城县| 新乡市| 彝良县| 光泽县| 贵阳市| 孝昌县| 定陶县| 泗阳县| 桦甸市| 全椒县| 濮阳市| 麦盖提县| 琼中| 仁寿县| 武义县| 体育| 西乌珠穆沁旗| 邵东县| 金塔县| 呼伦贝尔市| 金阳县| 吉木萨尔县| 巴青县| 威信县| 五指山市| 望都县| 临沭县| 河北省| 沧州市| 无棣县| 九龙县|