Jonathan. Jonathan. - 1 year ago 84 Question

Getting four bytes from a byte array in VB.NET

I have a byte array, and I need to get four bytes from it at a certain location (16), but I don't want to convert it to an integer or anything. Just keep it as four bytes to store in a variable.

Answer Source

If you have say:

byte[] source; // source array
byte[] dest=new byte[4];

Then you'd copy 4 bytes from source starting at 16 to dest like this:

Array.Copy(source, 16, dest, 0, 4);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download