如何在一个方法中删除一个数组中的元素,要求改变数组的长度!

大家看看我写的,但是无法改变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();
}
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网