"Vinny Vinn" <Vi*******@discussions.microsoft.com> wrote in message
news:84**********************************@microsof t.com...
What is the simplest way to combine one byte[] with another?
for example if i have
byte[] header = Encoding.ASCII.GetBytes("this is the header");
and
byte[] body = Encoding.ASCII.GetBytes("this is the body");
how can i combined them into one?
TIA,
Vinny
:) Here is one way.
byte[] header = System.Text.Encoding.ASCII.GetBytes(
"this is the header"
);
byte[] body = System.Text.Encoding.ASCII.GetBytes(
"this is the body"
);
byte[] contents = new byte[header.Length + body.Length];
Array.Copy(header, 0, contents, 0, header.Length);
Array.Copy(body, 0, contents, header.Length, body.Length);
string s = System.Text.Encoding.ASCII.GetString(contents);
Console.WriteLine(s);
HTH
Mythran