Getting Unmanaged struct data to C#

J

jcteague

What is the best way to get a set of unmanaged structs to C#.

I have the following structs:
typedef struct
{
unsigned char Angle[4];
unsigned char Rayon[3];
} StructPointPolaire;
//---------------------------------------------------------------------------
typedef struct
{
StructPointPolaire PointPolaire[36];
}StructForme36Points;
....
typedef struct
{
StructForme36Points Forme36Points;
...//more structs with similar data
char FinFichier[3];
} StructFormatMo1;

StructFormatMo1 is inside an unmanaged c++ class for which I have a
managed wrapper. The structs are filed in the constructor.

I need to access StructFormatMo1 (and the structs inside of course) in
C#. I won't be modifying the data and sending back to the c++
objects.

Thank you very much,
John
 
B

Ben Voigt

What is the best way to get a set of unmanaged structs to C#.

I have the following structs:
typedef struct
{
unsigned char Angle[4];
unsigned char Rayon[3];
} StructPointPolaire;
//---------------------------------------------------------------------------

Use an unsafe C# struct with the fixed keyword.

C++ unsigned char corresponds to C# byte.
typedef struct
{
StructPointPolaire PointPolaire[36];
}StructForme36Points;
...
typedef struct
{
StructForme36Points Forme36Points;
...//more structs with similar data
char FinFichier[3];
} StructFormatMo1;

StructFormatMo1 is inside an unmanaged c++ class for which I have a
managed wrapper. The structs are filed in the constructor.

I need to access StructFormatMo1 (and the structs inside of course) in
C#. I won't be modifying the data and sending back to the c++
objects.

Thank you very much,
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top