简体   繁体   中英

How to access elements of an array of bytes?

I have an array of bytes b returned from a C# code using Ironpython. If I use print b the output is as follows:

   Array[Byte]((<System.Byte object at 0x000000000000241A [175]>, 
    <System.Byte object at 0x000000000000241B [164]>,
     <System.Byte object at 0x000000000000241C [152]>, 
    <System.Byte object at 0x000000000000241D [68]>, 
    <System.Byte object at 0x000000000000241E [194]>, 
<System.Byte object at 0x000000000000241F [154]>, 
    <System.Byte object at 0x0000000000002420 [22]>,
     <System.Byte object at 0x0000000000002421 [197]>, 
    <System.Byte object at 0x0000000000002422 [130]>))

Can anyone please tell the meaning of this (numbers inside [] and System.Byte object at 0x00... )? Also how to access the individual elements?

Each of that are the references of the object inside your list, in this case has the type System.Byte, and the number in hexadecimal is the id of the reference. I if you take the first element de value will be 175 (in hexadecimal), is the value inside de []. So you only have to do a for bucle or something similar to get each value, the value before de [] are just the reference of the byte value in memory

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM