unboxing a string array object

P

psmith

I am getting data back from a COM object.

In the debugger, I get back an object as follows:

result -> system.array
[0,0]-> {length=102} string[,]
|
|--> [0,0] ="company 1" string
|--> [1,0] = "company 2" string
etc.

but i am having problems unboxing the information.

if I do int
length = (int)(string[,])((Array)result).Getlength(0)
I get length =1 not 102!!
and also I cannot get to string [0,0],[1,0] etc..

any help appreciated
 
N

Nicholas Paldino [.NET/C# MVP]

psmith,

When you call GetLength and pass in 0, you are getting the length of the
first dimension, which apparently is one. What you want to do is get the
length of everything. In that case, use the Length property on the Array
class.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top