.NET删除字节数组中的0字节

private static byte[] Decode(byte[] packet)
{
    var i = packet.Length - 1;
    while (packet[i] == 0)
    {
        --i;
    }
    var temp = new byte[i + 1];
    Array.Copy(packet, temp, i + 1);
    return temp;
}

 

posted @ 2016-09-05 14:05  FrankYou  阅读(588)  评论(0编辑  收藏  举报