How can I convert BitArray to single int?

后端 未结 4 902
借酒劲吻你
借酒劲吻你 2020-11-27 05:07

How can I convert BitArray to a single int?

4条回答
  •  渐次进展
    2020-11-27 05:46

    private int getIntFromBitArray(BitArray bitArray)
    {
    
        if (bitArray.Length > 32)
            throw new ArgumentException("Argument length shall be at most 32 bits.");
    
        int[] array = new int[1];
        bitArray.CopyTo(array, 0);
        return array[0];
    
    }
    

提交回复
热议问题