Please bear with me if my terminology is incorrect.
I'm attempting to extract data from an object. The object has a complex array which consist of rows and 6 columns per row.
I need to access the very last row in the array so I'm using .Count. The problem is a can't access the columns within the row. Here is the code:
var weight = USBHIDDRIVER.USBInterface.usbBuffer;
var cnt = weight.Count;
Debug.WriteLine(weight[cnt][4]);
USBHIDDRIVER.USBInterface.usbBuffer; contains data in the following format:
ROW [0] - COL [0] = 3
COL [1] = 4
COL [2] = 3
COL [3] = 255
COL [4] = 6
COL [5] = 0
Row [1] - COL [0] = 3
COL [1] = 4
COL [2] = 3
COL [3] = 255
COL [4] = 6
COL [5] = 0
etc, etc. Thanks in advance.
Because accessing a zero based List here, so you should be indexing the last field of the array using Count - 1
.
USBHIDDRIVER.USBInterface.usbBuffer
is an ArrayList
, so it's elements are of type object
. To have access to the elements of type byte[]
that were added to this list, you will have to typecast the elements to byte[]
:
Debug.WriteLine(((byte[])weight[cnt-1])[4]);
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加