您的位置:首页 > 编程语言 > C#

C# byte 数组合并

2011-03-15 10:23 197 查看
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.}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: