fixed arrays

L

leibnizster

Hello



I have a c++ unmanaged struct that has as one of its components an
array of constant length. To transform it in managed array I have to
use something like:

public struct blabla
{
....
fixed public char fixedArray[10];
....
}

when I use the struct, it is clear that fixedArray is of type char*.
The question is if i can use somehow fixedArray as an array, without
the pointer logic.

Thanks
 
M

Mattias Sjögren

The question is if i can use somehow fixedArray as an array, without
the pointer logic.

No you can't, it's not a real array. But perhaps you can change your
struct to

public struct blabla
{
....
[MarshalAs(UnmanagedType.ByValArray, SizeConst=10)]
public char[] fixedArray;
....
}


Mattias
 

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