I am somehow producing a C# object that contains another object structure. I am not sure how I can get hold of its content.
I have an array whose value is
{object[1,1]}
and type
object[,]
If I unfold it I get:
arr[0,0]
with value
{object[1..1]}
and with type
object{object[]}
and a structure that tells
[1]
with value (for the sake of argument)
myString
and with type
object{string}
I am not sure how I can get hold of the encapsulated string myString that I am searching for.
From the Watch window ((-) means that I unfolded the toggle point (+)):
Name Value Type
(-) arr {object[1,1]} object[,]
L (-) [0,0] {object[1..1]} object{object[]}
L [1] "myString" object{string}
arr[0,0][1] Cannot apply indexing with [] to an expression of type 'object'
Your array seems to be this, based on your last edit:
To get the value
myStringin code behind you can use thisobjArray[0,0][1]won't work because you aren't castingobjArray[0,0]to the type it is (an array), you can't use[1]on an instance of typeobjectvisual studio is doing underneath magic and will do the cast internally to access
[1]Here you can find a demo:
https://dotnetfiddle.net/VHFPmv