dar*_*ran 5 c# bit-manipulation bit
我有一大堆布尔值,我想将它们打包/解包成一个 uint 或类似的值。我怎样才能在 C# 中做到这一点?
您可以使用该类BitArray将数组转换bool为int数组:
int[] theIntArray = new int[(theBoolArray.Length + 31) / 32];
new BitArray(theBoolArray).CopyTo(theIntArray, 0);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4369 次 |
| 最近记录: |