System.Linq.Expressions.Error.ArgumentMustBeArrayIndexType C# (CSharp) Метод

ArgumentMustBeArrayIndexType() статический приватный Метод

ArgumentException with message like "Argument for array index must be of type Int32"
static private ArgumentMustBeArrayIndexType ( string paramName ) : Exception
paramName string
Результат System.Exception
        internal static Exception ArgumentMustBeArrayIndexType(string paramName)
        {
            return new ArgumentException(Strings.ArgumentMustBeArrayIndexType, paramName);
        }
        /// <summary>

Same methods

Error::ArgumentMustBeArrayIndexType ( string paramName, int index ) : Exception

Usage Example

Пример #1
0
        /// <summary>
        /// Creates an <see cref="IndexExpression"></see> to access an array.
        /// </summary>
        /// <param name="array">An expression representing the array to index.</param>
        /// <param name="indexes">An <see cref="IEnumerable{Expression}"/> containing expressions used to index the array.</param>
        /// <remarks>The expression representing the array can be obtained by using the MakeMemberAccess method,
        /// or through NewArrayBounds or NewArrayInit.</remarks>
        /// <returns>The created <see cref="IndexExpression"/>.</returns>
        public static IndexExpression ArrayAccess(Expression array, IEnumerable <Expression> indexes)
        {
            RequiresCanRead(array, "array");

            var arrayType = array.Type;

            if (!arrayType.IsArray)
            {
                throw Error.ArgumentMustBeArray();
            }

            var indexList = indexes.ToReadOnly();

            if (arrayType.GetArrayRank() != indexList.Count)
            {
                throw Error.IncorrectNumberOfIndexes();
            }

            foreach (var e in indexList)
            {
                RequiresCanRead(e, "indexes");
                if (e.Type != typeof(int))
                {
                    throw Error.ArgumentMustBeArrayIndexType();
                }
            }

            return(new IndexExpression(array, null, indexList));
        }
All Usage Examples Of System.Linq.Expressions.Error::ArgumentMustBeArrayIndexType
Error