How do I convert an array of unsigned chars to
array<unsigned char>^ ?
Thanks in advance!
Just create a managed array, and copy the data. Simple.
array<Byte>^ MakeManagedArray(unsigned char* input, int len)
{
array<Byte>^ result = gcnew array<Byte>(len);
for(int i = 0; i < len; i++)
{
result[i] = input[i];
}
return result;
}
Yes, I'm sure there's a way to use the Marshal class to do the copy for you, or to get a pointer to the managed array you can pass to memcpy
, but this works, and it doesn't require research on MSDN to verify that it's correct.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.