Types casting

edited September 2018 in Native
Hello! Is this right way to get Object from byte array or you can do something better?

nByte *byte_arr = new nByte[6];
//fill array
Object obj = ValueObject< nByte* >(byte_arr, 6);

Best regards.


  • Kaiserludi
    Kaiserludi admin
    edited October 2018
    Hi @angelskieglazki.

    If you don't actually need it (and you only need it if either you don't know the size of the array at compile time or if your array is huge (at least a couple millions of elements)), then I would recommend to get rid of the dynamic allocation and just allocate the array on the stack like this:
    nByte byte_arr[6];

    Aside from that: Yes, this is the right way to create an Object from a byte array.