W
Wild Wind
Hello,
I'm still trying to get to grips with managed C++.
I want to raise an event RaiseEvent which has as one
of its arguments a managed array.
The event will be raised in a function Func which will
take in an instance of an unmanaged class ByteArray.
ByteArray essentially wraps an array of bytes
(or chars) which you get using a serialize method, and
whose length you find out using the size method.
Here is my attempt below:
void Func(ByteArray ba)
{
int arrLen = ba.size();
System::Byte __pin baArray __gc[] = new System::Byte[arrLen];
char* baArray2 = &baArray[0];
ba.serialize(baArray2);
RaiseEvent(baArray);
}
What I am confused about is whether I need to put the __gc
in front of the array baArray that I will be passing in
RaiseEvent, or whether I have missed it elsewhere. I'm
also not sure whether I need to pin the array - I think
I should because I will be passing it to a function of
an unmanaged class.
Any clarification would be appreciated.
I'm still trying to get to grips with managed C++.
I want to raise an event RaiseEvent which has as one
of its arguments a managed array.
The event will be raised in a function Func which will
take in an instance of an unmanaged class ByteArray.
ByteArray essentially wraps an array of bytes
(or chars) which you get using a serialize method, and
whose length you find out using the size method.
Here is my attempt below:
void Func(ByteArray ba)
{
int arrLen = ba.size();
System::Byte __pin baArray __gc[] = new System::Byte[arrLen];
char* baArray2 = &baArray[0];
ba.serialize(baArray2);
RaiseEvent(baArray);
}
What I am confused about is whether I need to put the __gc
in front of the array baArray that I will be passing in
RaiseEvent, or whether I have missed it elsewhere. I'm
also not sure whether I need to pin the array - I think
I should because I will be passing it to a function of
an unmanaged class.
Any clarification would be appreciated.