我正在尝试在函数中写入数组中的整数,它总是显示“当前上下文中不存在名称'(数组名称)'”
int counter = int.Parse(Console.ReadLine());
int[] nums = new int[counter];
while (counter > 0)
{
nums[counter] = counter;
counter--;
}
(基本上创建了一个长度为用户选择的数组,并将数字从 1 到数组中的计数器) 在一些更改数组整数中的内容的代码之后 (计数器不会更改)
print(counter);
我创建的一个函数
public static void print(int count);
{
*some code*
while (count > 0)
{
Console.WriteLine(nums[count]); //line with the error
count--;
}
}
我期待它在 nums 数组中写入整数,但它没有。(顺便说一句,我需要把它写在函数里面,我稍后在代码中调用它)
茅侃侃
桃花长相依
相关分类