Skip to content

Cannot access index in properties of dynamic object #92

Description

@NielsUll

When trying to access vlues of an array (or dictionary) inside a dynamic object, I get the error:

DynamicExpresso.Exceptions.ParseException : No applicable indexer exists in type 'Object' (at index 7).

    [Test]
    public void Get_value_of_a_nested_array()
   {
       dynamic dyn = new ExpandoObject();
       dyn.Sub = new int[] {42};
       var interpreter = new Interpreter().SetVariable("dyn", (object)dyn);
       Assert.AreEqual(dyn.Sub[0], interpreter.Eval("dyn.Sub[0]"));
}

This is also mentioned on Stack Overflow, https://stackoverflow.com/questions/53040955/how-can-i-use-dynamic-variables-with-anonymous-types

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions