System.Linq.Expressions.Expression.ArrayAccess C# (CSharp) Method

ArrayAccess() public static method

Creates an IndexExpression to access an array.
The expression representing the array can be obtained by using the MakeMemberAccess method, or through NewArrayBounds or NewArrayInit.
public static ArrayAccess ( Expression array ) : IndexExpression
array Expression An expression representing the array to index.
return IndexExpression
        public static IndexExpression ArrayAccess(Expression array, params Expression[] indexes)
        {
            return ArrayAccess(array, (IEnumerable<Expression>)indexes);
        }

Same methods

Expression::ArrayAccess ( Expression array, IEnumerable indexes ) : IndexExpression

Usage Example

示例#1
0
        public void ArrayAccess()
        {
            var expected = LinqExpression.ArrayAccess(
                LinqExpression.Parameter(
                    typeof(int[])),
                LinqExpression.Parameter(
                    typeof(int)));

            using var g = new GraphEngine.Graph();
            g.LoadFromString(@"
@prefix : <http://example.com/> .

:s
    :arrayAccessArray [
        :parameterType [
            :typeName ""System.Int32[]"" ;
        ] ;
    ] ;
    :arrayAccessIndexes (
        [
            :parameterType [
                :typeName ""System.Int32"" ;
            ] ;
        ]
    ) ;
.
");
            var s = g.GetUriNode(":s");

            var actual = Expression.Parse(s).LinqExpression;

            Console.WriteLine(actual.GetDebugView());

            actual.Should().Be(expected);
        }
All Usage Examples Of System.Linq.Expressions.Expression::ArrayAccess
Expression