Convert BYTE* to Array<byte>^

c++-cx

Solution

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.

Problem

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); } ```

Original source