问题
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.
回答1:
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];
来源:https://stackoverflow.com/questions/46683441/access-violation-cannot-apply-indexing-with-to-an-expression-of-type-object