Home All Groups Group Topic Archive Search About

byte array concatenation

Author
17 Nov 2006 1:24 PM
Prasad
hi everyone,

This is prasad. I want to know how to concatenate two byte array
variables, can somebody help me.

thankx in advance.

Author
17 Nov 2006 2:06 PM
Herfried K. Wagner [MVP]
"Prasad" <prasad.***@gmail.com> schrieb:
> This is prasad. I want to know how to concatenate two byte array
> variables, can somebody help me.


Check out 'Buffer.BlockCopy'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
17 Nov 2006 5:51 PM
Prasad
Dear Herfried K Wagner,

Thank you Herfried K Wagner for your reply, I'm new to this method can
u please give an example for Buffer.BlockCopy. Please Don't mind that
my question sounds silly. I'm learning vb.net, I'm creating a client
and server application. Wherein the image stored in mysql database is
fetched from server application and passed to client application. I use
winsock connection, here i'm facing a problem in sending the image blob
data as byte from Server -> Client. I could able to see only half of
the image.

While tracing the program, the receiving function loops for 3 times. I
understood this is because the packet size handled here is large and so
it is being iterated for 3 times. So here i'm trying to concatenate the
byte array which is being executed for 3 times. Please suggest me an
efficient way to concatenate byte array.

Thanx in advance.
Author
17 Nov 2006 7:53 PM
Herfried K. Wagner [MVP]
"Prasad" <prasad.***@gmail.com> schrieb:
> Thank you Herfried K Wagner for your reply, I'm new to this method can
> u please give an example for Buffer.BlockCopy. Please Don't mind that
> my question sounds silly. I'm learning vb.net

No problem -- check out the sample below:

\\\
Dim Data1() As Byte = {1, 2, 3, 4}
Dim Data2() As Byte = {5, 6, 7, 8}
Dim Data(Data1.Length + Data2.Length - 1) As Byte
Buffer.BlockCopy(Data1, 0, Data, 0, Data1.Length)
Buffer.BlockCopy(Data2, 0, Data, Data1.Length, Data2.Length)
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>