所以我正在尝试使用 foreach 将值循环到一个二维数组中。我知道代码应该是这样的。
int calc = 0;
int[,] userfields = new int[3,3];
foreach (int userinput in userfields)
{
Console.Write("Number {0}: ", calc);
calc++;
userfields[] = Convert.ToInt32(Console.ReadLine());
}
这是我所能得到的。我尝试使用
userfields[calc,0] = Convert.ToInt32(Console.ReadLine());
但显然这不适用于二维数组。我对 C# 比较陌生,我正在努力学习,所以我很感激所有的答案。
提前致谢!