C# byte 数组合并

复制代码
 
 
01 . byte [] head = new byte [] { 0x7e }; 02 . byte [] type = new byte [] { 0x00 }; 03 . byte [] content = Encoding.Default.GetBytes( " ABCDEGF " ); 04 . byte [] last = new byte [] { 0x23 }; 05 . byte [] full = new byte [head.Length + type.Length + content.Length + last.Length]; 06 . // head.CopyTo(full,0); 07 . // type.CopyTo(full, head.Length); 08 . // content.CopyTo(full,head.Length+type.Length); 09 . // last.CopyTo(full, head.Length + type.Length + content.Length); 10 .Stream s = new MemoryStream(); 11 .s.Write(head, 0 , 1 ); 12 .s.Write(type, 0 , 1 ); 13 .s.Write(content, 0 ,content.Length); 14 .s.Write(last, 0 , 1 ); 15 .s.Position = 0 ; 16 . int r = s.Read(full, 0 , full.Length); 17 . if (r > 0 ) 18 .{ 19 . Console.WriteLine(Encoding.Default.GetString(full)); 20 . Console.WriteLine(full.Length); 21 . Console.WriteLine(full[ 0 ].ToString()); 22 . Console.WriteLine(full[ 1 ].ToString()); 23 . Console.WriteLine(full[ 9 ].ToString()); 24 . Console.Read(); 25 .}
复制代码


转自:http://www.cnblogs.com/jxsoft/archive/2011/03/15/1984535.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值