所以我試圖使用foreach循環值到一個二維數組。我知道代碼應該看起來像這樣。將值循環到具有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#相對較新,我正在努力學習,所以我非常感謝所有的答案。
在此先感謝!
什麼輸出你想?你的問題有點不清楚。此外,該代碼不會編譯。 – 2014-08-27 09:29:45
@ shree.pat18最後,我將把它作爲一個3x3表進行循環。 – Tatu 2014-08-27 09:32:48