Shifts a range of items in the array down one place - CSharp System

CSharp examples for System:Array Operation

Description

Shifts a range of items in the array down one place

Demo Code



public class Main{
        /// <summary>
        /// Shifts a range of items in the array down one place
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="arry">The array to be modified</param>
        /// <param name="removedItemIndex">The index of the item to be overwritten by this operation, all items one or more places higher than this will shift down one place</param>
        public static void ShiftDown<T>(this T[] arry, int removedItemIndex)
        {/*from   w  ww . j  a v  a2 s  .co m*/
            for(int i = removedItemIndex; i < (arry.Length - 1); i++)
            {
                arry[i] = arry[i + 1];
            }
        }
}

Related Tutorials