• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Extract data out of a seemingly complex structure

C

Curious

#1
I define a variable ("result") as object. Its value is set by
following code:

object result = splusObject.GetType().InvokeMember("ReturnValue",
System.Reflection.BindingFlags.GetProperty, null, splusObject, null);

Then both bad news and good news. Bad is that "result" seems to be a
matrix. In my debugger, it is:

Dimensions:[1..2, 1..2]}
[1, 1] 112

Good news is that it contains the correct value I want, "112".

I've tried to extract "112" out of result, but to no avail.

Any advice on how to extract "112" out of this complex structure of
result? Thanks!
 

My Computer

S

Stanimir Stoyanov

#2
Judging from the debugger output, 'result' is a jagged array. If you are
sure that the result is always a jagged array the following code will let
you extract the value at [1, 1]. Make sure there are enough elements in the
matrix though, in order to avoid receiving a IndexOutOfRangeException.

int[,] b = (int[,])result;
int resultValue = b[1, 1];

--
Stanimir Stoyanov
http://stoyanoff.info

"Curious" <fir5tsight@xxxxxx> wrote in message
news:3494ebbd-ceb9-4887-a0f5-bcc221d0c5bd@xxxxxx

>I define a variable ("result") as object. Its value is set by
> following code:
>
> object result = splusObject.GetType().InvokeMember("ReturnValue",
> System.Reflection.BindingFlags.GetProperty, null, splusObject, null);
>
> Then both bad news and good news. Bad is that "result" seems to be a
> matrix. In my debugger, it is:
>
> Dimensions:[1..2, 1..2]}
> [1, 1] 112
>
> Good news is that it contains the correct value I want, "112".
>
> I've tried to extract "112" out of result, but to no avail.
>
> Any advice on how to extract "112" out of this complex structure of
> result? Thanks!
>
>
>
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)