我有一些舊的代碼是這樣的:位在C#中移混亂
private int ParseByte(byte theByte)
{
byte[] bytes = new byte[1];
bytes[0] = theByte;
BitArray bits = new BitArray(bytes);
if (bits[0])
return 1;
else
return 0;
}
它的長,我想我可以修剪下來是這樣的:
private int ParseByte(byte theByte)
{
return theByte >> 7;
}
但是,我沒有變與第一個函數相同的值。該字節包含00000000或10000000.我在這裏錯過了什麼?我是否使用不正確的操作符?
因此,我用來查看數據的十六進制編輯器顯示爲10000000.我想它先顯示lsb?我在BitArray中感到困惑時感到幸運? – scottm 2009-06-16 16:09:20