CSharp · Console
using System;
public class Program
{
static int ? [] array = new int ? []{4, 3, 1, 2, 100, 8, 7, 73, 64, 10};
public static void Main(string[] args)
{
Delete(3);
foreach(var item in array)
{
Console.WriteLine(item);
}
}
public static void Delete(int index)
{
if (index >= array.Length)
{
return;
}
if (index == array.Length - 1)
{
array[index] = null;
}
for (int i = index; i < array.Length - 1; i++)
{
array[i] = array[i + 1];
}
array[array.Length - 1] = null;
}
}