Removing trailing nulls from byte array in C#

前端 未结 10 2055
感情败类
感情败类 2020-12-30 03:01

Ok, I am reading in dat files into a byte array. For some reason, the people who generate these files put about a half meg\'s worth of useless null bytes at the end of the

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-30 03:09

    You could just count the number of zero at the end of the array and use that instead of .Length when iterating the array later on. You could encapsulate this however you like. Main point is you don't really need to copy it into a new structure. If they are big, it may be worth it.

提交回复
热议问题