Convert BYTE* to Array<byte>^

FYK

Is it possible to convert byte* to Array^ in C++/CX?

Currently I accomplish this by copying each value, which I know is not space/performance efficient.

My current implementation is :

Array<byte>^ arr = ref new Array<byte>(byteCount);
for (int i = 0; i < byteCount; i++)
{
    arr[i] = *(bytes + i);
}
Andy Rich

There's an array constructor for that (MSDN): Array(T* data, unsigned int size);

So in your case, simply do: Array<byte>^ arr = ref new Array<byte>(bytes, byteCount);

This is a great article on C++/CX and WinRT array patterns.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related