1、对象转为byte[] 数据
/// <summary>/// 将对象转化为字节数字/// </summary>/// <param name="obj">需要转化对象</param>/// <returns></returns>public static byte[] ConvertToBytes(this object obj){ using (var stream = new MemoryStream()) { var formatter=new BinaryFormatter(); formatter.Serialize(stream,obj); return stream.GetBuffer(); }}
2、对象转为Stream类型
/// <summary>/// 对象转为数据流/// </summary>/// <param name="obj">需要转化的对象</param>/// <returns></returns>public static MemoryStream ConvertToStream(this object obj){ using (var stream = new MemoryStream()) { var formatter = new BinaryFormatter(); formatter.Serialize(stream, obj); return stream; }}
原文转载:http://www.shaoqun.com/a/488092.html
邮乐网购:https://www.ikjzd.com/w/1776
haofang:https://www.ikjzd.com/w/1046
韩国naver:https://www.ikjzd.com/w/1727
1、对象转为byte[]数据///<summary>///将对象转化为字节数字///</summary>///<paramname="obj">需要转化对象</param>///<returns></returns>publicstaticbyte[]ConvertToBytes(thisobjectobj
e票联:https://www.ikjzd.com/w/1452
关键词分析工具:https://www.ikjzd.com/w/1968
常平金竹湾水上乐园有更衣室吗?金竹湾水上欢乐世界淋浴有吗?:http://tour.shaoqun.com/a/71670.html
亚马逊常见的listing问题汇总,以及listing变体新玩法!:https://www.ikjzd.com/home/8701
宁夏香喷喷的扣麒麟顶 - :http://tour.shaoqun.com/a/50127.html
No comments:
Post a Comment