1

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.

Or Rosenblum
  • 41
  • 1
  • 7

1 Answers1

3

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];
NightOwl888
  • 55,572
  • 24
  • 139
  • 212