The array length is set when you instantiate the array, and can't be
changed after that.
ArrayLists on the other hand can grow and shrink in size. But I
generally wouldn't recommend using that a replacement for a byte[]
since every byte would be boxed.
You can't change the length, but you could allocate a new array of larger
size and copy current array into it.
byte[] SetLenght(byte[] currByteArray, int newSize)
{
if ( currByteArray.Length > newSize)
//error
byte[] newArray = new byte[newSize];
// copy currArray to newArray.
return newArray;
}
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.