Sep 26, 2010 10:49 AM
(This post was last modified: Sep 26, 2010 11:10 AM by ubbelol.)
Very simple function I made to "merge" or append multiple byte arrays, can't find the word for it.
Example usage:
Code
private byte[] mergeBytes(byte[][] inputBytes)
{
int tmp = 0;
byte[] output;
foreach (byte[] bArr in inputBytes){
tmp += bArr.Length;
}
output = new byte[tmp]; tmp = 0;
foreach (byte[] bArr in inputBytes){
Buffer.BlockCopy(bArr, 0, output, tmp, bArr.Length); tmp += bArr.Length;
}
return output;
}Example usage:
Code
byte[] b = new byte[7]; b = Encoding.Default.GetBytes("UbbeLoL");
byte[] b2 = new byte[3]; b2 = Encoding.Default.GetBytes("123");
string str = Encoding.Default.GetString(mergeBytes(new byte[][] { b, b2 })); //<- str = UbbeLoL123
Probably coding some useless shit.

