简体   繁体   中英

c# Trying to get byte[] data from an object in an Array

I have been working on this one for a while, searching forums and Microsoft articles but so far none of what I have found has helps, so I need to ask the experts.

I have been working with a COM reference (third party DLL) in my C# project where one of the outputs gives me some payload data. I am trying to get the byte[] data out into clear text for debugging purposes but here is where I run into problems.

If I watch the Locals during debug, I see that the returned System.Array has three Objects. Each object contains a byte[] (value{byte[253]}) , two bytes and a uint.

If I run the following I can get the objects from the Array, but I am stuck trying to get the byte[] data out of the object.

for (int i = 0; i < myArray.Length; i++ )
{
     object myObject = myArray.GetValue(i);
}

Can anyone give me some advice?

Can't you do simply the following?

byte[] byteArray = myArray.GetValue(i)[0];

Your question is a little vague, but I think this will help.

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