How do I convert this expression from C++ to C#?
struct MyStruct
{
uint8_t *rcSource;
uint8_t *rcMask;
uint32_t *clientAuthSchemes;
}
The structure is initialised in C++ this way:
MyStruct st;
st.rcSource = (uint8_t*) malloc(width*height);
st.rcMask = (开发者_如何转开发uint8_t*) malloc(width*height);
st.clientAuthSchemes = (uint32_t*) malloc(sizeof(uint32_t)*(size+1));
If those are 1-dimensional arrays, you probably want something like this:
struct MyStruct
{
public byte[] rcSource;
public byte[] rcMask;
public uint[] clientAuthSchemes;
}
Initialization:
MyStruct st;
st.rcSource = new byte[width*height];
st.rcMask = new byte[width*height];
st.clientAuthSchemes = new uint[size+1];
I believe this is the way:
struct MyStruct
{
sbyte rcSource, rcMask;
int clientAuthSchemes;
}
:)
精彩评论