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.
-
Duplicate of stackoverflow.com/questions/943635/…Sedat Kapanoglu– Sedat Kapanoglu2010-01-02 14:46:56 +00:00Commented Jan 2, 2010 at 14:46
-
1yep except then I have to attempt converting it to vb.netJonathan.– Jonathan.2010-01-02 14:56:49 +00:00Commented Jan 2, 2010 at 14:56
Add a comment
|
1 Answer
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);
1 Comment
Blindy
@PeterMortensen, if English isn't your first language, do try to avoid editing answers, at least the non-code portions.