Reputation: 41
I have the following variable: _Data.
The variable contains the following info: _Data Variable
How can i access the message field?
I tried _Data["messages"][0]
- but it not wokring.
I recieved the following error: Cannot apply indexing with [] to an expression of type 'object'
What am i doing wrong?
Thanks.
Upvotes: 1
Views: 5292
Reputation: 56859
What am i doing wrong?
_Data["messages"]
is returning type object
. You need to cast it to List<string>
or IList<string>
in order to use an indexer.
var indexable = _Data["messages"] as IList<string>; // The image is cut off - not sure if this should be string or not
if (indexable != null)
return indexable[0];
Upvotes: 3