ArrayAccess vs. ArrayIndex in the expression tree

What is the difference between the two? From the API documentation, it seems like they should have done the same.

Arrayaccess

against.

Arrayindex

In this case, they seem redundant, so I have to skip something here.

+8
c # linq expression-trees
source share
1 answer

Edit: my original answer was so erroneous that I try again.

Expression.ArrayAccess returns an IndexExpression that can be used to get or set the value of an element in an array.

Expression.ArrayIndex returns either BinaryExpression or MethodCallExpression depending on the rank (number of dimensions) of the provided array expression. The returned expression can then be used to read the value from the array.

So ArrayAccess gives you an expression that provides both read and write access for the data in the array, while ArrayIndex gives you read-only access.

+10
source share

All Articles