views:

88

answers:

1

I have a structure in C++ that I want to reflect in C# code (goover all field and initiate with specific order) that I want to dump the structure memeory as binary data into a file. I have a problem in array decleration in the sturct if I declare int dummy_4[10] the compiler raise error that can't mix managed & unmanaged types. if I delare as array etc... and initialize the array in the constructor, the array doesn't locate after dummy_3 in the memory and I can't dump it to the file.

Neeed some ideas how to solve it. Thanks

public ref struct Dummy_t
{
    int dummy_1;
    int dummy_2;
    int dummy_3;
//int dummy_4[2];  X compile error mix managed and unmanaged types
    array<int>^ dummy_4; 
    int dummy_5;
    Dummy_t()
    {
 dummy_4 = gcnew array<uint8_t>(2);
    }

};
A: 

You can write a custom dump method in Dummy_t, which takes care about dummy_4, and outputs the values from the array pointed to.

Vlad