In C# how can I truncate a byte[] array

后端 未结 6 710
太阳男子
太阳男子 2021-01-03 18:27

I have a byte[] array of one size, and I would like to truncate it into a smaller array?

I just want to chop the end off.

6条回答
  •  生来不讨喜
    2021-01-03 18:42

    You can't truncate an array in C#. They are fixed in length.

    If you want a data structure that you can truncate and acts like an array, you should use List. You can use the List.RemoveRange method to achieve this.

提交回复
热议问题