Accessing elements of types with indexers using expression trees
问题 Suppose I have a type like this: class Context { SomeType[] Items { get; set; } } I want to be able to access specific Items elements using expression trees. Suppose I need an element at index 0 . I can do it like below, where everything works as expected: var type = typeof (Context); var param = Expression.Parameter(typeof (object)); var ctxExpr= Expression.Convert(param, context); var proInfo = type.GetProperty("Items"); Expression.ArrayIndex(Expression.Property(ctxExpr, proInfo),