需要将Python中的位掩码转换为VB.NET

问题描述 投票:0回答:1

我有一些Python 3代码使用掩码从字节数组中提取信息,但是我需要在VB.NET程序中进行操作。这是Python。

modulation_indicies = ['Unknown','Normal','High','Low']
phs_noise = int.from_bytes(block_data[0x1E:0x20],byteorder='little')  & 0x01FFF
mod_index = modulation_indicies[(int.from_bytes(block_data[0x1E:0x20],byteorder='little')  & 0x0C000) >> 14]

其中block_data是字节数组。我的系统是little_endian。在VB.NET中如何编码?我已经尝试了来自不同论坛的几件事,但我无法理解。

python-3.x vb.net bit-shift masking
1个回答
0
投票
Enum Modulation_indicies
    Jumbo
    ExtraLarge
    Large
    Medium
    Small
End Enum

Sub Main()

    phs_noise = BitConverter.ToInt32(you_write_this, 0) And &H1FFF
    mod_index = Modulation_indicies(phs_noise And &HC000 >> 14)

End Sub
© www.soinside.com 2019 - 2024. All rights reserved.