This question has already been answered:
- Analogue of bit field in C # 1 response
Help me figure out what it means
:
In the variable below I will give the structure in C ++ Builder:
typedef struct { unsigned int nr:8; // unsigned int y:8; // 1 unsigned int sm:3; // 2 unsigned int d:5; // 3 unsigned int m:4; // 4 unsigned int r:4; // 5 } n_def; What exactly is the number after? nr:8 or 3 or 5 ..... etc? And how to implement the same thing in C #?
The fact is that I need to read data from a binary file, and how do I understand, first I need to read the entire block and then break it into bits? in C #, reading is as follows:
using (BinaryReader reader = new BinaryReader(File.Open(path, FileMode.Open))) { // пока не достигнут конец файла // считываем каждое значение из файла while (reader.PeekChar() > -1) { int numb = reader.ReadInt32(); uint nr = reader.ReadUInt32(); // переменная которую нужно разбить на биты } } I understood correctly? how to properly implement? can better use marshaling? thank you for your responses