I am reading a binary file of a specific format, and am used to being able to cast a block of data to a struct then reading the struct to pull fields out of the binary datafile.
I'm trying to do this but failing in C#, they seem more like classes than structures in the C sense. Is it possible to do what I want? For example..
public struct Datum {
byte type;
ushort payload;
}
public struct DiskPage {
ushort pageNumber;
Datum[] data = Datum[170];
}
I want to be able to read 512 bytes of a file and cast it to a DiskPage, then to be able to read the values from the DiskPage structure. Is this possible in c# - or is there another preferred approach? Should I just leave that code in C and link it in?
Thanks! Reza