System.Linq.Expressions.NewArrayExpression.Update C# (CSharp) Method

Update() public method

Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression.
public Update ( IEnumerable expressions ) : NewArrayExpression
expressions IEnumerable The property of the result.
return NewArrayExpression
        public NewArrayExpression Update(IEnumerable<Expression> expressions)
        {
            if (expressions == Expressions)
            {
                return this;
            }
            if (NodeType == ExpressionType.NewArrayInit)
            {
                return Expression.NewArrayInit(Type.GetElementType(), expressions);
            }
            return Expression.NewArrayBounds(Type.GetElementType(), expressions);
        }
    }

Usage Example

示例#1
0
        /// <summary>
        ///     Visits the children of the <see cref="NewArrayExpression" />.
        /// </summary>
        /// <param name="node">The expression to visit.</param>
        /// <returns>
        ///     The modified expression, if it or any subexpression was modified;
        ///     otherwise, returns the original expression.
        /// </returns>
        protected internal virtual Expression VisitNewArray(NewArrayExpression node)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            return(node.Update(Visit(node.Expressions)));
        }
All Usage Examples Of System.Linq.Expressions.NewArrayExpression::Update