大家看看我写的,但是无法改变source数组的长度,有啥好方法
public int[] delete(int[] source,int number){
int i;
for(i=number-1;i<source.length-1;i++){
source[i]=source[i+1];
}
int[] temp=new int[source.length-1];
copy(source,temp,temp.length);
return temp;
}
public static int[] Delete(int[] input, int index)
{
if (input == null || input.Length <= 0 || index < 0 || index > input.Length - 1)
throw new ArgumentException();
List<int> temp = new List<int>(input);
temp.RemoveAt(index);
return temp.ToArray();
}
{
if (input == null || input.Length <= 0 || index < 0 || index > input.Length - 1)
throw new ArgumentException();
List<int> temp = new List<int>(input);
temp.RemoveAt(index);
return temp.ToArray();
}
温馨提示:答案为网友推荐,仅供参考