locked
How to convert a Plaform::Array<unsigned char> to unsigned char*

    Question

  • Hello, I'm trying to get the data from a Platform::Array<unsigned char> to a unsigned int pointer and I'm doning in the following way:

    Platform::Array<unsigned char>^ arrByte = ref new Platform::Array<unsigned char>(count);
    
    reader->ReadBytes(arrByte);
    
    uint8 *lReceivedBytes = new uint8[count];
    
    for(int i = 0; i < count; i++)
    {    
        lReceivedBytes[i] = arrByte[i];
    }

    I would like to know if there's a more eficient way to do that.

    Thank you

    Friday, September 28, 2012 3:43 PM

Answers

  • You can try these codes

    uint8 *lReceivedBytes = new uint8[count];
    lReceivedBytes=arrByte->Data;

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us


    • Edited by Jesse Jiang Monday, October 1, 2012 7:09 AM
    • Marked as answer by Hugetto Monday, October 1, 2012 9:15 AM
    Monday, October 1, 2012 7:08 AM

All replies

  • Why not use Value property of Array class ?
    Saturday, September 29, 2012 8:02 PM
  • You can try these codes

    uint8 *lReceivedBytes = new uint8[count];
    lReceivedBytes=arrByte->Data;

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us


    • Edited by Jesse Jiang Monday, October 1, 2012 7:09 AM
    • Marked as answer by Hugetto Monday, October 1, 2012 9:15 AM
    Monday, October 1, 2012 7:08 AM