How to add a byte to the beginning of an existing byte array? My goal is to make array what's 3 bytes long to 4 bytes. So that's why I need to add 00 padding in the beginning of it.
You can't do that. It's not possible to resize an array. You have to create a new array and copy the data to it:
bArray = AddByteToArray(bArray,  newByte);  code:
public byte[] AddByteToArray(byte[] bArray, byte newByte) {     byte[] newArray = new byte[bArray.Length + 1];     bArray.CopyTo(newArray, 1);     newArray[0] = newByte;     return newArray; } 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With