How to split a byte array

前端 未结 7 1821
一个人的身影
一个人的身影 2020-12-03 20:20

I have a byte array in memory, read from a file. I would like to split the byte array at a certain point (index) without having to just create a new byte array and copy eac

7条回答
  •  清歌不尽
    2020-12-03 21:25

    I'm not sure what you mean by:

    I would like to split the byte array at a certain point(index) without having to just create a new byte array and copy each byte at a time, increasing the in memory foot print of the operation.

    In most languages, certainly C#, once an array has been allocated, there is no way to change the size of it. It sounds like you're looking for a way to change the length of an array, which you can't. You also want to somehow recycle the memory for the second part of the array, to create a second array, which you also can't do.

    In summary: just create a new array.

提交回复
热议问题