You're on the right track. Just assign a value.
int[,] matarix = new int[4, 5];
for (int x = 0; x < 4; x++) {
for (int y = 0; y < 5; y++) {
matarix[x, y] = VALUE_HERE;
}
}
One recommendation I would make, would be to use Array.GetLength
instead of hard coding your for
loops. Your code would become:
int[,] matarix = new int[4, 5];
for (int x = 0; x < matarix.GetLength(0); x++) {
for (int y = 0; y < matarix.GetLength(1); y++) {
matarix[x, y] = VALUE_HERE;
}
}
You pass in one of the array's dimensions, and it tells you how many indices exist for that dimension.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…