1
我正在使用c#并且遇到流动问题: 我在循环ant之前减速了高度变量,它说周期中不存在。在循环中声明的变量不存在于循环中c#
在这部分代码中,我希望程序存储“data”数组除第一个元素之外的所有第3个元素,所以如果“data”数组看起来像这样:1,2,3,4, 5,6,7,8,9,10,11,12 ...我想得到:6,9,12 ...
static int[] tall()
{
int[] data = database();//recalling an array filled with numbers
int j = 0;
int[] height;
for (int i = 6; i < data.Length;)
{
i = i + 3;
j++;
height[j] = data[i];//Use of unassigned local variable 'height'
}
return height;
}
我不知道*周期*但是你必须像'int [] height = new int [data.Length];'或'int [] height = new int [data.Length - 6];初始化你的数组; – Habib 2014-11-20 16:50:34