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

ArgumentException with message like "Parameter index '{0}' is out of bounds for method '{1}'"
static private ParameterIndexOutOfBounds ( object p0, object p1 ) : Exception
p0 object
p1 object
Результат System.Exception
Пример #1
0
        /// <summary>
        /// Creates a positional subpattern that matches a component extracted by calling a Deconstruct method.
        /// </summary>
        /// <param name="pattern">The pattern to apply to the object in the corresponding position.</param>
        /// <param name="method">The Deconstruct method used to extract the object to match on.</param>
        /// <param name="parameterIndex">The index of the parameter on the Deconstruct method used to extract the object to match on.</param>
        /// <returns>A <see cref="PositionalCSharpSubpattern" /> representing a positional subpattern.</returns>
        public static PositionalCSharpSubpattern PositionalSubpattern(CSharpPattern pattern, MethodInfo method, int parameterIndex)
        {
            RequiresNotNull(method, nameof(method));

            var parameters = method.GetParametersCached();

            if (parameterIndex < 0 || parameterIndex >= parameters.Length)
            {
                throw Error.ParameterIndexOutOfBounds(parameterIndex, method.Name);
            }

            return(PositionalSubpattern(pattern, parameters[parameterIndex]));
        }
Пример #2
0
        public static ParameterAssignment Bind(MethodBase method, int index, Expression expression)
        {
            // NB: This overload is needed for the compiler to emit factory calls;
            //     we can't emit a `ldtoken` instruction to obtain a ParameterInfo.

            ContractUtils.RequiresNotNull(method, nameof(method));

            var parameters = method.GetParametersCached();

            if (index < 0 || index >= parameters.Length)
            {
                throw Error.ParameterIndexOutOfBounds(index, method.Name);
            }

            return(Bind(parameters[index], expression));
        }