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

C#byte数组合并

2010-03-25 16:34 357 查看
byte[] head = new byte[] { 0x7e };
byte[] type = new byte[] { 0x00 };
byte[] content = Encoding.Default.GetBytes("ABCDEGF");
byte[] last = new byte[] { 0x23 };
byte[] full=new byte[head.Length+type.Length+content.Length+last.Length];
//head.CopyTo(full,0);
//type.CopyTo(full, head.Length);
//content.CopyTo(full,head.Length+type.Length);
//last.CopyTo(full, head.Length + type.Length + content.Length);
Stream s = new MemoryStream();
s.Write(head, 0, 1);
s.Write(type,0,1);
s.Write(content,0,content.Length);
s.Write(last, 0, 1);
s.Position = 0;
int r = s.Read(full, 0, full.Length);
if (r>0)
{
Console.WriteLine(Encoding.Default.GetString(full));
Console.WriteLine(full.Length);
Console.WriteLine(full[0].ToString());
Console.WriteLine(full[1].ToString());
Console.WriteLine(full[9].ToString());
Console.Read();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: