如何在asp.net中连接两个byte []值 [英] how to concatenate two byte[] values in asp.net
本文介绍了如何在asp.net中连接两个byte []值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友
我想将byte []数组值连接到asp.net中的单个byte []中.我在asp.net中找不到正确的代码
请任何人能帮助我:
thanx
hi friends
i want to concatenate to byte[] array values into single byte[] in asp.net. i could not find right code for it in asp.net
please can anyone help me:
thanx
推荐答案
我使用此函数连接2个或更多字节数组
I use this function to concat 2 or more byte arrays
private byte[] CombineByteArrays(params byte[][] arrays)
{
byte[] rv = new byte[arrays.Sum(a => a.Length)];
int offset = 0;
foreach (byte[] array in arrays)
{
System.Buffer.BlockCopy(array, 0, rv, offset, array.Length);
offset += array.Length;
}
return rv;
}
我使用这样的功能
I the use the function like this
byte[] header, body, footer; // All byte arrays a fill with data
byte[] content = CombineByteArrays(header, body, footer);
networkStream1.Write(content, 0, content.Length);
此处有几种合法方法: ^ ].
还要这样: ^ ]
There are several legitimate methods here: http://stackoverflow.com/questions/415291/best-way-to-combine-2-or-more-byte-arrays-in-c[^].
Also this: http://www.google.com/search?source=ig&hl=en&rlz=&q=concatenate+byte+arrays+c%23&aq=f&aqi=&aql=&oq=[^]
这篇关于如何在asp.net中连接两个byte []值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文