我有一个具有不同值的数组。一个名为saveforRR的数组,这应该像每当我有任何小于0的值一样工作,它将被从数组中删除。此外,数组中的值必须减少1.我不知道要使我的数组长度= 0需要多少次迭代。所以我用while循环。但是,当我运行代码时,我的循环在此行中停止 fortheaddingvalue =(int)saveforRR [w]; //它告诉她我的阵列是从边界出来的,我不知道怎么做?我该如何解决这个问题?你能告诉我吗?
//Create variables and set up the arrays
int value = 7;
int [] saveforRR = {1,2,3,4,5,15,86};
//start get the values reduced
int fortheaddingvalue;
int w = 0;
//Run the while loop to reduce the value in the saveforRR array.
while(saveforRRName.Length !=0 && saveforRR.Length !=0)
{
fortheaddingvalue = (int)saveforRR[w]; //It says her that my array is out from boundaries, which i do not know how?
fortheaddingvalue = fortheaddingvalue - 1;
if (fortheaddingvalue > 0)
{
saveforRR[w] = fortheaddingvalue;
txtOutput.Text += "\r\n" +saveforRR[w] + " this is the value";
}
else
{
Array.Clear(saveforRR, w, 1);
txtOutput.Text += "\r\n" + saveforRR[w] + "this is the value Remover";
}
w++;
}