I have two byte arrays - array1 and array2 . My aim is to copy the bytes from 1st array to second with respect to the start index of each array and fill the non filled bytes with a specific byte.
byte[] array1 = new byte[5]
The data is as follows: 11,22,00,33,44;
byte[] array2 = new byte[10];
I need to copy the bytes from array1 to array2. The data needs to be copied from position 3 in array2 and fill the rest of the empty positions with value ff. ie my result in array2 would be {ff,ff,ff,11,22,00,33,44,ff,ff}
Any help would be appreciable.
Thanks in advance!
Array.Copyoverload that lets you control the start index of the copy action. So create an array, initialise all elements toffthen copy on top of it (this would make for the simplest code). And here you are :-)Array.Copy(). This is just needs a simple calculation of the offsets involved.