コード例 #1
0
ファイル: Array.cs プロジェクト: r3ne-pew/Notenleuchte
        /// <summary>
        /// Sets the specified element in the current Array to the specified
        /// value.
        /// </summary>
        /// <param name="value">
        /// The new value for the specified element.
        /// </param>
        /// <param name="index">
        /// An integer that represents the position of the Array element to set.
        /// </param>
        /// <returns>
        /// A new array with the element at the specified position set to the
        /// specified value.
        /// </returns>
        /// <exception cref="ArgumentOutOfRangeException">
        /// index is outside the range of valid indexes for the current Array.
        /// </exception>
        public Array SetValue(object value, int index)
        {
            // Preconditions.
            if (index < 0 || index >= Length)
            {
                throw new ArgumentOutOfRangeException(
                          "Index out of range.");
            }

            return(new Array(head.SetValue(value, index), Length));
        }
コード例 #2
0
        /// <summary>
        /// Sets the specified element in the current RandomAccessList to the
        /// specified value.
        /// </summary>
        /// <param name="value">
        /// The new value for the specified element.
        /// </param>
        /// <param name="index">
        /// An integer that represents the position of the RandomAccessList
        /// element to set.
        /// </param>
        /// <returns>
        /// A new RandomAccessList with the element at the specified position
        /// set to the specified value.
        /// </returns>
        /// <exception cref="ArgumentOutOfRangeException">
        /// index is outside the range of valid indexes for the current
        /// RandomAccessList.
        /// </exception>
        public RandomAccessList SetValue(object value, int index)
        {
            // Precondition.
            if (index < 0 || index >= Count)
            {
                throw new ArgumentOutOfRangeException("index", index,
                                                      "Index out of range.");
            }

            return(new RandomAccessList(first.SetValue(value, index), Count));
        }