Struct {
byte F1[2]
SHORT F2
byte F3[512]
} BPD
CBD
{
SHORT CLENGTH
byte DATA[]
}
Above are 2 c++ structure. Here SHORT is of 2 byte signed.
What would be the best way to convert it into C#?
(Note that in 2nd struture length of DATA is uundefined.)
I have seen following two links.
Fixed length strings or structures in C#
and
Reading a C/C++ data structure in C# from a byte array
After reading data into structure i need to covert the short variable to big endian. (reversing bytes).
Solved myself.
Structures are good but if you are not going to modify any data classes are better to use.
I have create classes in c# for c++ structure and for big to little endian conversion i have create 3 library functions and it works for me.
Thnaks everybody for the valuable input.