Exemplo n.º 1
0
        /// <summary>
        /// Returns the element for the given index.
        /// </summary>
        /// <typeparam name="T">The type of the elements in the array</typeparam>
        /// <param name="arrayIndexer">The array indexer</param>
        /// <param name="array">The array</param>
        /// <param name="indices">The array indices.</param>
        /// <returns>The element at the location specified by the supplied indices.</returns>
        public static T Index <T>(this ArrayIndexer arrayIndexer, T[] array, params int[] indices)
        {
            if (arrayIndexer == null)
            {
                throw new ArgumentNullException(nameof(arrayIndexer));
            }
            if (array == null)
            {
                throw new ArgumentNullException(nameof(array));
            }

            return(array[arrayIndexer.ToIndex(indices)]);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the element for the given index.
        /// </summary>
        /// <param name="arrayIndexer">The array indexer</param>
        /// <param name="array">The array</param>
        /// <param name="indices">The array indices.</param>
        /// <returns>The element at the location specified by the supplied indices.</returns>
        public static object Index(this ArrayIndexer arrayIndexer, Array array, params int[] indices)
        {
            if (arrayIndexer == null)
            {
                throw new ArgumentNullException(nameof(arrayIndexer));
            }
            if (array == null)
            {
                throw new ArgumentNullException(nameof(array));
            }

            return(array.GetValue(arrayIndexer.ToIndex(indices)));
        }