R
robert.waters
I have to parse a binary file having a number of fixed records, each
record containing datas in fixed positions. I would like to parse
this binary file into an array of structures having members that
represent those fields, so that I can access the records in a
meaningful way.
Using C, I would have defined a struct that I could cast a byte array
into, which held exactly one of these fixed records. The struct would
be defined as such:
struct rec {
char index[1] ;
char padding[50];
char name[28];
};
No big deal, (rec)char_array;.
I tried to do something similar in C#, and I am getting an error
telling me that:
"Array size cannot be specified in a variable declaration"
How might I create a data structure with fixed-size members at design
time?
Do I really have to encapsulate this into a class that contains logic
to parse the record sequentially when it's instantiated?
Thanks.
record containing datas in fixed positions. I would like to parse
this binary file into an array of structures having members that
represent those fields, so that I can access the records in a
meaningful way.
Using C, I would have defined a struct that I could cast a byte array
into, which held exactly one of these fixed records. The struct would
be defined as such:
struct rec {
char index[1] ;
char padding[50];
char name[28];
};
No big deal, (rec)char_array;.
I tried to do something similar in C#, and I am getting an error
telling me that:
"Array size cannot be specified in a variable declaration"
How might I create a data structure with fixed-size members at design
time?
Do I really have to encapsulate this into a class that contains logic
to parse the record sequentially when it's instantiated?
Thanks.