how to add 2 byte arrays in VB.NET?

  • Thread starter Thread starter Khanh
  • Start date Start date
K

Khanh

hi all,

How to solve the problem like below in VB.NET :

Dim temp1() as byte
Dim temp2() as byte
Dim result() as byte

'---- init a binary reader with a webresponse
BinaryReader.Read(temp1,0,1000)
BinaryReader.Read(temp2,1000,1000)
redim preserve result(2000)
result = result + temp1 + temp2 '<--- how to implement this line

The reason why we have to fulfill this snippet of code is we want to
retrieve an image throught http web request from a web server. So we
have to read a part of image then concatenate them together.

Thanks in advance
Khanh
 
Khanh said:
How to solve the problem like below in VB.NET :

Dim temp1() as byte
Dim temp2() as byte
Dim result() as byte

'---- init a binary reader with a webresponse
BinaryReader.Read(temp1,0,1000)
BinaryReader.Read(temp2,1000,1000)
redim preserve result(2000)
result = result + temp1 + temp2 '<--- how to implement this line

The reason why we have to fulfill this snippet of code is we want to
retrieve an image throught http web request from a web server. So we
have to read a part of image then concatenate them together.

One easy way is just to use a MemoryStream to build up the data as you
go.

Alternatively, you can use Array.Copy to copy the items from one array
to another - create a new array that's big enough to hold the whole
result, and then copy each of the source arrays into place
appropriately.
 
Back
Top