public class RemoveElementByIndexArray
public static void Main(string[] args)
public static void RemoveByTheIndexArray()
int[] myArray = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
int index = Array.IndexOf(myArray, elementToRemove);
Console.WriteLine("The index of the element to remove is: {0}",index);
int[] copyArray = (int[])myArray.Clone();
int[] newArray = new int[copyArray.Length - 1];
Console.Write("The array after removing the \"{0}\" element from {1} position is: ",elementToRemove,index);
if (index != myArray.Length)
for (int i = 0; i < index; i++)
newArray[i] = copyArray[i];
for (int i = index; i < copyArray.Length - 1; i++)
newArray[i] = copyArray[i + 1];
foreach (int number in newArray)
Console.Write("{0}, ", number.ToString());
for (int i = 0; i < copyArray.Length - 1; i++)
newArray[i] = copyArray[i];