我有一个结构,我需要填充和写入磁盘(实际上几个).
一个例子是:
byte-6
bit0 - original_or_copy
bit1 - copyright
bit2 - data_alignment_indicator
bit3 - PES_priority
bit4-bit5 - PES_scrambling control.
bit6-bit7 - reserved
Run Code Online (Sandbox Code Playgroud)
在CI中可能会执行以下操作:
struct PESHeader {
unsigned reserved:2;
unsigned scrambling_control:2;
unsigned priority:1;
unsigned data_alignment_indicator:1;
unsigned copyright:1;
unsigned original_or_copy:1;
};
Run Code Online (Sandbox Code Playgroud)
有没有办法在C#中做到这一点,使我能够使用struct dereferencing点运算符访问位?
对于几个结构,我可以在访问器函数中进行包裹移位.
我有很多结构要以这种方式处理,所以我正在寻找一些更容易阅读和更快写的东西.